package com.netsdk.demo.customize;

import com.netsdk.demo.util.CaseMenu;
import com.netsdk.demo.util.DateUtil;
import com.netsdk.demo.util.sql.EventDto;
import com.netsdk.demo.util.sql.JdbcUtils;
import com.netsdk.demo.util.sql.Trafic;
import com.netsdk.demo.util.sql.Trajectory;
import com.netsdk.lib.NetSDKLib;
import com.netsdk.lib.ToolKits;
import com.netsdk.lib.enumeration.*;
import com.netsdk.lib.structure.*;
import com.netsdk.lib.utils.Initialization;
import com.netsdk.module.entity.ShiJian;
import com.sun.jna.Pointer;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.sql.*;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.Date;
import static com.netsdk.lib.NetSDKLib.NET_MAX_DETECT_REGION_NUM;

public class RealLoadPicExDemo extends Initialization {

    int channel= -1;

    NetSDKLib.LLong    attachHandle=new NetSDKLib.LLong(0);
    ShiJian sj = new ShiJian();
    public RealLoadPicExDemo() throws SQLException {
    }

    /**
     * 订阅智能任务
     */
    public NetSDKLib.LLong AttachEventRealLoadPic() {
        // 先退订，设备不会对重复订阅作校验，重复订阅后会有重复的事件返回
        if(attachHandle.longValue()!=0){
            this.DetachEventRealLoadPic();
        }

        // 需要图片
        int bNeedPicture = 1;
        attachHandle = netSdk.CLIENT_RealLoadPictureEx(loginHandle, channel, EM_EVENT_TYPE.EVENT_IVS_ALL.getType(), bNeedPicture,
                RealLoadPicExDemo.AnalyzerDataCB.getInstance(), null, null);
        if (attachHandle.longValue() != 0) {
            System.out.printf("Chn[%d] CLIENT_RealLoadPictureEx Success\n", channel);
        } else {
            System.out.printf("Chn[%d] CLIENT_RealLoadPictureEx Failed!LastError = %s\n", channel,
                    ToolKits.getErrorCode());
        }

        return attachHandle;
    }
    /**
     * 报警事件（智能）回调
     */
    private static class AnalyzerDataCB implements NetSDKLib.fAnalyzerDataCallBack {
        private final File picturePath;
        private static RealLoadPicExDemo.AnalyzerDataCB instance;


        private AnalyzerDataCB() {
            picturePath = new File("C:\\juyuan\\devtoos\\apache-tomcat-8.5.65\\webapps\\qxjtImg");
            if (!picturePath.exists()) {
                picturePath.mkdirs();
            }
        }

        public static RealLoadPicExDemo.AnalyzerDataCB getInstance() {
            if (instance == null) {
                instance = new RealLoadPicExDemo.AnalyzerDataCB();
            }
            return instance;
        }

        @Override
        public int invoke(NetSDKLib.LLong lAnalyzerHandle, int dwAlarmType, Pointer pAlarmInfo, Pointer pBuffer, int dwBufSize,
                          Pointer dwUser, int nSequence, Pointer reserved) throws UnsupportedEncodingException, SQLException {
            if (lAnalyzerHandle == null || lAnalyzerHandle.longValue() == 0) {
                return -1;
            }

            System.out.println("===================================EVENT RECEIVED=======================================");
//            System.out.println(Objects.requireNonNull(EM_EVENT_IVS_TYPE.getEventType(dwAlarmType)).getDescription());
            switch (Objects.requireNonNull(EM_EVENT_IVS_TYPE.getEventType(dwAlarmType))) {
                // 1行人检测
                case EVENT_IVS_TRAFFIC_PEDESTRAIN:
              {
                    EventDto dto = new EventDto();
                    dto.setEvent_name("行人检测");
                    dto.setEvent_code(dwAlarmType+"");
                    //创建事件对象
                    DEV_EVENT_TRAFFIC_THROW_INFO msg = new DEV_EVENT_TRAFFIC_THROW_INFO();
                    //加载事件新信息
                    ToolKits.GetPointerData(pAlarmInfo, msg);

                    // 通道号 对应设备
                    int nChannelID = msg.nChannelID;
                    System.out.println("nChannelID:" + nChannelID);
                    dto.setChannel(nChannelID+"");
                    //事件名称
                    byte[] szName = msg.szName;
                    //相对事件时间戳(单位是毫秒)
                    double pts = msg.PTS;
                    dto.setEvent_time(DateUtil.format(new Date((long) pts), "yyyy-MM-dd HH:mm:ss.SSS"));
                    //UTC时间
                    NET_TIME_EX UTC = msg.UTC;
                    System.out.println("UTC:" + UTC.toStringTime());
                    dto.setEvent_utc_time(UTC.toStringTime());
                    //事件id
                    int nEventID = msg.nEventID;
                    dto.setEvent_id(nEventID+"");
                    //事件对应文件信息
                    NetSDKLib.NET_EVENT_FILE_INFO stuFileInfo = msg.stuFileInfo;
                    dto.setEvent_content(stuFileInfo.toString());
                    //图片分辨率
                    NetSDKLib.NET_RESOLUTION_INFO stuResolution = msg.stuResolution;
                    dto.setImg_fbl(stuResolution.toString());
                    //图片
                    int picSizes = 0;
                    NetSDKLib.NET_PIC_INFO stPicInfo = msg.stuObject.stPicInfo;
                  //图片保存
                  if (pBuffer != null) {
                      String pName = System.currentTimeMillis() + "related_EVENT_IVS_DREGS_UNCOVERED.jpg";
                      String picture = picturePath + "/" + pName;
                      if(null != pBuffer){
                          dto.setImg_name(pName);
                      }
                      ToolKits.savePicture(pBuffer, 0, dwBufSize, picture);
                  }
                    //抓图标志(按位),0位:"*",1位:"Timing",2位:"Manual",3位:"Marked",4位:"Event",5位:"Mosaic",6位:"Cutout"
                    int dwSnapFlagMask = msg.dwSnapFlagMask;
                    dto.setImg_mask(dwSnapFlagMask+"");
                    //事件动作,0表示脉冲事件,1表示持续性事件开始,2表示持续性事件结束
                    byte bEventAction = msg.bEventAction;
                    dto.setEvent_dz(String.valueOf(bEventAction));
                    //智能事件所属大类
                    int ClassType = msg.stuIntelliCommInfo.emClassType;
                    dto.setEvent_class(ClassType+"");
                    //对应车道号
                    int nLane = msg.nLane;
                    dto.setLane(nLane+"");
                    JdbcUtils.insert(dto);
                    break;
                }
                // 2停车检测
                case EVENT_IVS_TRAFFIC_PARKING:
                {
                    EventDto dto = new EventDto();
                    dto.setEvent_name("停车检测");
                    dto.setEvent_code(dwAlarmType+"");
                    DEV_EVENT_DREGS_UNCOVERED_INFO msg = new DEV_EVENT_DREGS_UNCOVERED_INFO();

                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 通道号
                    int nChannelID = msg.nChannelID;
                    System.out.println("nChannelID:" + nChannelID);
                    dto.setChannel(nChannelID+"");
                    //事件名称
                    byte[] szName = msg.szName;
                    dto.setSzName( new String(msg.szName,"UTF-8").trim());
                    //相对事件时间戳(单位是毫秒)
                    double pts = msg.PTS;
                    dto.setEvent_time(DateUtil.format(new Date((long) pts), "yyyy-MM-dd HH:mm:ss.SSS"));
                    //UTC时间
                    NET_TIME_EX UTC = msg.UTC;
                    System.out.println("UTC:" + UTC.toStringTime());
                    dto.setEvent_utc_time(UTC.toStringTime());
                    //事件id
                    int nEventID = msg.nEventID;
                    dto.setEvent_id(nEventID+"");
                    //智能事件所属大类
                    int ClassType = msg.emClassType;
                    dto.setEvent_class(ClassType+"");
                    //检测区域,[0,8191]
                    int nDetectRegionNum = msg.nDetectRegionNum;
                    dto.setRegion(nDetectRegionNum+"");
                    //事件对应文件信息
                    String stuDetectRegions = "";
                    NetSDKLib.NET_POINT[] stuDetectRegion = msg.stuDetectRegion;
                    for(int i = 0; i < NET_MAX_DETECT_REGION_NUM; i ++){
                        // System.out.println("stuDetectRegion[" + i + "]:" + stuDetectRegion[i].toString());
                        stuDetectRegions = stuDetectRegions + stuDetectRegion[i].toString()+",";
                    }
                    dto.setEvent_code(stuDetectRegions);
                    //车辆信息
                    DREGS_UNCOVERED_VEHICLE_INFO stuVehicleInfo = msg.stuVehicleInfo;

                    dto.setStu_Vehicle_Info(new String(stuVehicleInfo.szPlateNumber).trim());
                    //图片保存
                    if (pBuffer != null) {
                        String pName = System.currentTimeMillis() + "related_EVENT_IVS_DREGS_UNCOVERED.jpg";
                        String picture = picturePath + "/" + pName;
                        if(null != pBuffer){
                            dto.setImg_name(pName);
                        }
                        ToolKits.savePicture(pBuffer, 0, dwBufSize, picture);
                        System.out.println("图片:" + picture);
                    }
                    JdbcUtils.insert(dto);

                    break;
                }
                //交通抛洒物品事件
               case EVENT_IVS_TRAFFIC_THROW : {
                    EventDto dto = new EventDto();
                    dto.setEvent_name("交通抛洒物品事件");
                    dto.setEvent_code(dwAlarmType+"");
                    DEV_EVENT_TRAFFIC_THROW_INFO msg = new DEV_EVENT_TRAFFIC_THROW_INFO();

                    ToolKits.GetPointerData(pAlarmInfo, msg);

                    // 通道号
                    int nChannelID = msg.nChannelID;
                    System.out.println("nChannelID:" + nChannelID);
                    dto.setChannel(nChannelID+"");
                    //事件名称
                    byte[] szName = msg.szName;
                    //相对事件时间戳(单位是毫秒)
                    double pts = msg.PTS;
                    dto.setEvent_time(DateUtil.format(new Date((long) pts), "yyyy-MM-dd HH:mm:ss.SSS"));
                    //UTC时间
                    NET_TIME_EX UTC = msg.UTC;
                    System.out.println("UTC:" + UTC.toStringTime());
                    dto.setEvent_utc_time(UTC.toStringTime());
                    //事件id
                    int nEventID = msg.nEventID;
                    dto.setEvent_id(nEventID+"");
                    //事件对应文件信息
                    NetSDKLib.NET_EVENT_FILE_INFO stuFileInfo = msg.stuFileInfo;
                    dto.setEvent_content(stuFileInfo.toString());
                    //图片分辨率
                    NetSDKLib.NET_RESOLUTION_INFO stuResolution = msg.stuResolution;
                    dto.setImg_fbl(stuResolution.toString());
                    //图片
                    int picSizes = 0;
                    NetSDKLib.NET_PIC_INFO stPicInfo = msg.stuObject.stPicInfo;
                    dto.setImg_name(stPicInfo.toString());
                   //图片保存
                   if (pBuffer != null) {
                       String pName = System.currentTimeMillis() + "related_EVENT_IVS_DREGS_UNCOVERED.jpg";
                       String picture = picturePath + "/" + pName;
                       if(null != pBuffer){
                           dto.setImg_name(pName);
                       }
                       ToolKits.savePicture(pBuffer, 0, dwBufSize, picture);
                   }
                    //抓图标志(按位),0位:"*",1位:"Timing",2位:"Manual",3位:"Marked",4位:"Event",5位:"Mosaic",6位:"Cutout"
                    int dwSnapFlagMask = msg.dwSnapFlagMask;
                    dto.setImg_mask(dwSnapFlagMask+"");
                    //事件动作,0表示脉冲事件,1表示持续性事件开始,2表示持续性事件结束
                    byte bEventAction = msg.bEventAction;
                    dto.setEvent_dz(String.valueOf(bEventAction));
                    //智能事件所属大类
                    int ClassType = msg.stuIntelliCommInfo.emClassType;
                    dto.setEvent_class(ClassType+"");
                    //对应车道号
                    int nLane = msg.nLane;
                    dto.setLane(nLane+"");
                    JdbcUtils.insert(dto);
                    break;
                }
                // 逆行检测
               case EVENT_IVS_TRAFFIC_RETROGRADE:
                {
                    EventDto dto = new EventDto();
                    dto.setEvent_name("逆行检测");
                    dto.setEvent_code(dwAlarmType+"");
                    DEV_EVENT_DREGS_UNCOVERED_INFO msg = new DEV_EVENT_DREGS_UNCOVERED_INFO();

                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 通道号
                    int nChannelID = msg.nChannelID;
                    System.out.println("nChannelID:" + nChannelID);
                    dto.setChannel(nChannelID+"");
                    //事件名称
                    byte[] szName = msg.szName;
                    dto.setSzName( new String(msg.szName,"UTF-8").trim());
                    //相对事件时间戳(单位是毫秒)
                    double pts = msg.PTS;
                    dto.setEvent_time(DateUtil.format(new Date((long) pts), "yyyy-MM-dd HH:mm:ss.SSS"));
                    //UTC时间
                    NET_TIME_EX UTC = msg.UTC;
                    System.out.println("UTC:" + UTC.toStringTime());
                    dto.setEvent_utc_time(UTC.toStringTime());
                    //事件id
                    int nEventID = msg.nEventID;
                    dto.setEvent_id(nEventID+"");
                    //智能事件所属大类
                    int ClassType = msg.emClassType;
                    dto.setEvent_class(ClassType+"");
                    //检测区域,[0,8191]
                    int nDetectRegionNum = msg.nDetectRegionNum;
                    dto.setRegion(nDetectRegionNum+"");
                    //事件对应文件信息
                    String stuDetectRegions = "";
                    NetSDKLib.NET_POINT[] stuDetectRegion = msg.stuDetectRegion;
                    for(int i = 0; i < NET_MAX_DETECT_REGION_NUM; i ++){
                        stuDetectRegions = stuDetectRegions + stuDetectRegion[i].toString()+",";
                    }
                    dto.setEvent_code(stuDetectRegions);
                    //车辆信息
                    DREGS_UNCOVERED_VEHICLE_INFO stuVehicleInfo = msg.stuVehicleInfo;
                    dto.setStu_Vehicle_Info(new String(stuVehicleInfo.szPlateNumber).trim());
                    //图片保存
                    if (pBuffer != null) {
                        String pName = System.currentTimeMillis() + "related_EVENT_IVS_DREGS_UNCOVERED.jpg";
                        String picture = picturePath + "/" + pName;
                        if(null != pBuffer){
                            dto.setImg_name(pName);
                        }
                        ToolKits.savePicture(pBuffer, 0, dwBufSize, picture);
                    }
                    JdbcUtils.insert(dto);
                    break;
                }
                // 倒车检测
               case EVENT_IVS_TRAFFIC_BACKING:
                {
                    EventDto dto = new EventDto();
                    dto.setEvent_name("倒车检测");
                    dto.setEvent_code(dwAlarmType+"");
                    DEV_EVENT_DREGS_UNCOVERED_INFO msg = new DEV_EVENT_DREGS_UNCOVERED_INFO();

                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 通道号
                    int nChannelID = msg.nChannelID;
                    System.out.println("nChannelID:" + nChannelID);
                    dto.setChannel(nChannelID+"");
                    //事件名称
                    byte[] szName = msg.szName;
                    dto.setSzName( new String(msg.szName,"UTF-8").trim());
                    //相对事件时间戳(单位是毫秒)
                    double pts = msg.PTS;
                    dto.setEvent_time(DateUtil.format(new Date((long) pts), "yyyy-MM-dd HH:mm:ss.SSS"));
                    //UTC时间
                    NET_TIME_EX UTC = msg.UTC;
                    System.out.println("UTC:" + UTC.toStringTime());
                    dto.setEvent_utc_time(UTC.toStringTime());
                    //事件id
                    int nEventID = msg.nEventID;
                    dto.setEvent_id(nEventID+"");
                    //智能事件所属大类
                    int ClassType = msg.emClassType;
                    dto.setEvent_class(ClassType+"");
                    //检测区域,[0,8191]
                    int nDetectRegionNum = msg.nDetectRegionNum;
                    dto.setRegion(nDetectRegionNum+"");
                    //事件对应文件信息
                    String stuDetectRegions = "";
                    NetSDKLib.NET_POINT[] stuDetectRegion = msg.stuDetectRegion;
                    for(int i = 0; i < NET_MAX_DETECT_REGION_NUM; i ++){
                        stuDetectRegions = stuDetectRegions + stuDetectRegion[i].toString()+",";
                    }
                    dto.setEvent_code(stuDetectRegions);
                    //车辆信息
                    DREGS_UNCOVERED_VEHICLE_INFO stuVehicleInfo = msg.stuVehicleInfo;
                    dto.setStu_Vehicle_Info(new String(stuVehicleInfo.szPlateNumber).trim());
                    //图片保存
                    if (pBuffer != null) {
                        String pName = System.currentTimeMillis() + "related_EVENT_IVS_DREGS_UNCOVERED.jpg";
                        String picture = picturePath + "/" + pName;
                        if(null != pBuffer){
                            dto.setImg_name(pName);
                        }
                        ToolKits.savePicture(pBuffer, 0, dwBufSize, picture);
                    }
                    JdbcUtils.insert(dto);
                    break;
                }
                // 交通非机动车事件检测
              case EVENT_IVS_TRAFFIC_NONMOTOR:
                {
                    System.out.println("交通非机动车事件检测, code = " + dwAlarmType);
                    DEV_EVENT_TRAFFIC_NONMOTOR_INFO msg = new DEV_EVENT_TRAFFIC_NONMOTOR_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 通道号
                    int nChannelID = msg.nChannelID;
                    System.out.println("nChannelID:" + nChannelID);
                    // 动作
                    int nAction = msg.nAction;
                    System.out.println("nAction:" + nAction);
                    // 规则
                    int nRuleId = msg.nRuleId;
                    System.out.println("nRuleId:" + nRuleId);
                    // 触发方式
                    int emTriggerType = msg.emTriggerType;
                    System.out.println("emTriggerType:" + emTriggerType + "," + EM_TRIGGER_TYPE.getNoteByValue(emTriggerType));
                    //事件名称
                    byte[] szName = msg.szName;
                    System.out.println("szName UTF-8:" + new String(szName,"UTF-8").trim());
                    System.out.println("szName GBK:" + new String(szName,"GBK").trim());
                    //相对事件时间戳(单位是毫秒)
                    double pts = msg.PTS;
                    System.out.println("pts:" + new Date((long) pts));
                    //UTC时间
                    NET_TIME_EX UTC = msg.UTC;
                    System.out.println("UTC:" + UTC.toStringTime());
                    //事件id
                    int nEventID = msg.nEventID;
                    System.out.println("nEventID:" + nEventID);
                    EventDto dto = new EventDto();
                    //图片保存
                    if (pBuffer != null && dwBufSize > 0) {
                        System.out.println("basic picture received!");
                        String pName = System.currentTimeMillis() + "related_TrafficNoMotor_basic.jpg";
                        String bigPicture = picturePath + "\\" + pName;
                        if(null != pBuffer){
                            dto.setBigPicture(pName);
                        }
                        ToolKits.savePicture(pBuffer, dwBufSize, bigPicture);
                    }
                    //图片保存
                    if (pBuffer != null) {
                        String pName = System.currentTimeMillis() + "related_EVENT_IVS_DREGS_UNCOVERED.jpg";
                        String picture = picturePath + "/" + pName;
                        if(null != pBuffer){
                            dto.setImg_name(pName);
                        }
                        ToolKits.savePicture(pBuffer, 0, dwBufSize, picture);
                    }
                    if (pBuffer != null && dwBufSize > 0 && msg.stuNonMotor.stuSceneImage.nLength > 0) {
                        System.out.println("Scene picture received!");
                        String pName = System.currentTimeMillis() + "related_TrafficNoMotor_scene.jpg";
                        String scenePicture = picturePath + "\\" + pName;
                        if(null != pBuffer){
                            dto.setScenePicture(pName);
                        }
                        ToolKits.savePicture(pBuffer, msg.stuNonMotor.stuSceneImage.nOffSet, msg.stuNonMotor.stuSceneImage.nLength , scenePicture);
                    }
                    if (pBuffer != null && dwBufSize > 0 && msg.stuNonMotor.stuFaceSceneImage.nLength > 0) {
                        System.out.println("face picture received!");
                        String pName = System.currentTimeMillis() + "related_TrafficNoMotor_face.jpg";
                        String facePicture = picturePath + "\\" + pName;
                        if(null != pBuffer){
                            dto.setFacePicture(pName);
                        }
                        ToolKits.savePicture(pBuffer, msg.stuNonMotor.stuFaceSceneImage.nOffSet, msg.stuNonMotor.stuFaceSceneImage.nLength , facePicture);
                    }
                    //图片保存
                    if (pBuffer != null && dwBufSize > 0 && msg.stuCommInfo.nPictureNum > 0) {
                        System.out.println(msg.stuCommInfo.nPictureNum + " pictures received!");
                        for(int i = 0; i < msg.stuCommInfo.nPictureNum; i ++){
                            String pName = System.currentTimeMillis() + "related_TrafficJam_common_"+i+".jpg";
                            String bigPicture = picturePath + "\\" + pName;
                            if(null != pBuffer){
                                dto.setBigPicture(StringUtils.isNotEmpty(dto.getBigPicture()) ? dto.getBigPicture() + ","+pName : ""+pName );
                            }
                            ToolKits.savePicture(pBuffer, msg.stuCommInfo.stuPicInfos[i].nOffset, msg.stuCommInfo.stuPicInfos[i].nLength, bigPicture);
                        }
                    }

                    dto.setEvent_name("交通非机动车事件检测");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel(nChannelID+"");
                    dto.setnAction(nAction+"");
                    dto.setRule_Id(nRuleId+"");
                    dto.setEvent_utc_time(UTC.toStringTime());
                    dto.setSzName(new String(msg.szName,"UTF-8").trim());
                    dto.setTriggertType(emTriggerType+"");
                    dto.setEvent_time(DateUtil.format(new Date((long) pts), "yyyy-MM-dd HH:mm:ss.SSS"));
                    dto.setEvent_id(nEventID+"");
                    dto.setEvent_utc_time(UTC.toStringTime());
                    JdbcUtils.insert(dto);
                    break;
                }
                // 交通拥堵
                case EVENT_IVS_TRAFFICJAM:
                {
                    EventDto dto = new EventDto();
                    System.out.println("交通拥堵事件, code = " + dwAlarmType);
                    dto.setEvent_name("交通拥堵事件");
                    dto.setEvent_code(dwAlarmType+"");
                    NetSDKLib.DEV_EVENT_TRAFFICJAM_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFICJAM_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 通道号
                    int nChannelID = msg.nChannelID;
                    dto.setChannel(nChannelID+"");
                    System.out.println("nChannelID:" + nChannelID);
                    // 车道号
                    int nLane = msg.nLane;
                    System.out.println("nLane:" + nLane);
                    dto.setLane(nLane+"");
                    // 报警时间间隔
                    int nAlarmIntervalTime = msg.nAlarmIntervalTime;
                    System.out.println("nAlarmIntervalTime:" + nAlarmIntervalTime);
                    dto.setnAlarmIntervalTime(nAlarmIntervalTime+"");
                    //事件名称
                    byte[] szName = msg.szName;
                    System.out.println("szName UTF-8:" + new String(szName,"UTF-8").trim());
                    System.out.println("szName GBK:" + new String(szName,"GBK").trim());
                    dto.setSzName(new String(szName,"UTF-8").trim());
                    //相对事件时间戳(单位是毫秒)
                    double pts = msg.PTS;
                    System.out.println("pts:" + new Date((long) pts));
                    dto.setEvent_time(DateUtil.format(new Date((long) pts), "yyyy-MM-dd HH:mm:ss.SSS"));

                    //事件id
                    int nEventID = msg.nEventID;
                    System.out.println("nEventID:" + nEventID);
                    dto.setEvent_id(nEventID+"");
                    //图片保存
                    if (pBuffer != null && dwBufSize > 0 && msg.stCommInfo.nPictureNum > 0) {
                        System.out.println(msg.stCommInfo.nPictureNum + " pictures received!");
                        for(int i = 0; i < msg.stCommInfo.nPictureNum; i ++){
                            String pName = System.currentTimeMillis() + "related_TrafficJam_common_" + i + ".jpg";
                            String bigPicture = picturePath + "\\" + pName;
                            if(null != pBuffer){
                                dto.setBigPicture(StringUtils.isNotEmpty(dto.getBigPicture()) ? dto.getBigPicture() + ","+pName : ""+pName );
                            }

                            ToolKits.savePicture(pBuffer, msg.stCommInfo.stuPicInfos[i].nOffset, msg.stCommInfo.stuPicInfos[i].nLength, bigPicture);
                        }
                    }
                    //交通车辆信息扩展
                    NET_TRAFFICCAR_INFO_EXTERN stInfo = new NET_TRAFFICCAR_INFO_EXTERN();
                    ToolKits.GetPointerData(msg.stTrafficCar.pTrafficInfoExtern,stInfo);
                    System.out.println("stInfo.bAverageSpeed = " + stInfo.bAverageSpeed);
                    System.out.println("stInfo.bSpaceOcpRatio = " + stInfo.bSpaceOcpRatio);
                    System.out.println("stInfo.dAverageSpeed = " + stInfo.dAverageSpeed);
                    System.out.println("stInfo.dSpaceOcpRatio = " + stInfo.dSpaceOcpRatio);
                    System.out.println("stInfo.nContainerNumber = " + stInfo.nContainerNumber);
                    System.out.println("stInfo.nContainerTextNum = " + stInfo.nContainerTextNum);
                    String nContainerTextNum = "";
                    for(int i = 0; i < stInfo.nContainerTextNum; i ++){
                        byte[] tmp = new byte[64];
                        System.arraycopy(stInfo.szContainerText, i * 64, stInfo.nContainerTextNum, 0, 64);
                        String text = new String(tmp).trim();
                        System.out.println("stInfo.nContainerTextNum[" + i + "] = " + text);
                        nContainerTextNum = nContainerTextNum + text + ",";
                    }
                    dto.setnContainerTextNum(nContainerTextNum);
                    JdbcUtils.insert(dto);

                    break;
                }
                // 交通事故事件
                case EVENT_IVS_TRAFFIC_REAREND_ACCIDENT:
                {
                    System.out.println("交通事故事件, code = " + dwAlarmType);
                    DEV_EVENT_TRAFFIC_REAREND_ACCIDENT_INFO msg = new DEV_EVENT_TRAFFIC_REAREND_ACCIDENT_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 通道号
                    EventDto dto = new EventDto();
                    int nChannelID = msg.nChannelID;
                    System.out.println("nChannelID:" + nChannelID);
                    // 动作
                    int nAction = msg.nAction;
                    System.out.println("nAction:" + nAction);
                    // 车道号
                    int nLaneID = msg.nLaneID;
                    System.out.println("nLaneID:" + nLaneID);
                    // 抓拍过程
                    int emCaptureProcess = msg.emCaptureProcess;
                    System.out.println("emCaptureProcess:" + emCaptureProcess + "," + EM_CAPTURE_PROCESS_END_TYPE.getNoteByValue(emCaptureProcess));
                    //事件名称
                    byte[] szName = msg.szName;
                    System.out.println("szName UTF-8:" + new String(szName,"UTF-8").trim());
                    System.out.println("szName GBK:" + new String(szName,"GBK").trim());
                    //相对事件时间戳(单位是毫秒)
                    double pts = msg.PTS;
                    System.out.println("pts:" + new Date((long) pts));
                    //UTC时间
                    NET_TIME_EX UTC = msg.UTC;
                    System.out.println("UTC:" + UTC.toStringTime());
                    //事件id
                    int nEventID = msg.nEventID;
                    System.out.println("nEventID:" + nEventID);
                    //图片保存
                    if (pBuffer != null && dwBufSize > 0 && msg.stuCommInfo.nPictureNum > 0) {
                        System.out.println(msg.stuCommInfo.nPictureNum + " pictures received!");
                        for(int i = 0; i < msg.stuCommInfo.nPictureNum; i ++){
                            String pName = System.currentTimeMillis() + "related_TrafficAccident_common_" + i + ".jpg";
                            String bigPicture = picturePath + "\\" + pName;
                            if(null != pBuffer){
                                dto.setBigPicture(StringUtils.isNotEmpty(dto.getBigPicture()) ? dto.getBigPicture() + ","+pName : ""+pName );
                            }
                            ToolKits.savePicture(pBuffer, msg.stuCommInfo.stuPicInfos[i].nOffset, msg.stuCommInfo.stuPicInfos[i].nLength, bigPicture);
                        }
                    }

                    dto.setEvent_name("交通事故事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel(nChannelID+"");
                    dto.setnAction(nAction+"");
                    dto.setLane(nLaneID+"");
                    dto.setEvent_utc_time(UTC.toStringTime());
                    dto.setEmCaptureProcess(emCaptureProcess+"");
                    dto.setSzName(new String(szName,"UTF-8").trim());
                    dto.setEvent_time(DateUtil.format(new Date((long) pts), "yyyy-MM-dd HH:mm:ss.SSS"));
                    dto.setEvent_id(nEventID+"");
                    JdbcUtils.insert(dto);
                    break;
                }
                // 施工检测
               /* case EVENT_IVS_TRAFFIC_ROAD_CONSTRUCTION:
                {
                    System.out.println("施工检测, code = " + dwAlarmType);
                    DEV_EVENT_TRAFFIC_REAREND_ACCIDENT_INFO msg = new DEV_EVENT_TRAFFIC_REAREND_ACCIDENT_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 通道号
                    int nChannelID = msg.nChannelID;
                    System.out.println("nChannelID:" + nChannelID);
                    // 车道号
                    int nLaneID = msg.nLaneID;
                    System.out.println("nLaneID:" + nLaneID);
                    //事件名称
                    byte[] szName = msg.szName;
                    System.out.println("szName UTF-8:" + new String(szName,"UTF-8").trim());
                    System.out.println("szName GBK:" + new String(szName,"GBK").trim());
                    //相对事件时间戳(单位是毫秒)
                    double pts = msg.PTS;
                    System.out.println("pts:" + new Date((long) pts));
                    //UTC时间
                    NET_TIME_EX UTC = msg.UTC;
                    System.out.println("UTC:" + UTC.toStringTime());
                    //事件id
                    int nEventID = msg.nEventID;
                    System.out.println("nEventID:" + nEventID);
                    EventDto dto = new EventDto();
                    //图片保存
                    if (pBuffer != null && dwBufSize > 0 && msg.stuCommInfo.nPictureNum > 0) {
                        System.out.println(msg.stuCommInfo.nPictureNum + " pictures received!");
                        for(int i = 0; i < msg.stuCommInfo.nPictureNum; i ++){
                            String pName = System.currentTimeMillis() + "related_TrafficAccident_common_" + i + ".jpg";
                            String bigPicture = picturePath + "\\" + pName;
                            if(null != pBuffer){
                                dto.setBigPicture(StringUtils.isNotEmpty(dto.getBigPicture()) ? dto.getBigPicture() + ","+pName : ""+pName );
                            }
                            ToolKits.savePicture(pBuffer, msg.stuCommInfo.stuPicInfos[i].nOffset, msg.stuCommInfo.stuPicInfos[i].nLength, bigPicture);
                        }
                    }

                    dto.setEvent_name("施工检测");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel(nChannelID+"");
                    dto.setLane(nLaneID+"");
                    dto.setEvent_utc_time(UTC.toStringTime());
                    dto.setSzName(new String(szName,"UTF-8").trim());
                    dto.setEvent_time(DateUtil.format(new Date((long) pts), "yyyy-MM-dd HH:mm:ss.SSS"));
                    dto.setEvent_id(nEventID+"");
                    JdbcUtils.insert(dto);
                    break;
                }*/
                // 路障检测
               /* case EVENT_IVS_TRAFFIC_ROAD_BLOCK:
                {
                    System.out.println("路障检测, code = " + dwAlarmType);
                    DEV_EVENT_TRAFFIC_REAREND_ACCIDENT_INFO msg = new DEV_EVENT_TRAFFIC_REAREND_ACCIDENT_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 通道号
                    int nChannelID = msg.nChannelID;
                    System.out.println("nChannelID:" + nChannelID);
                    // 车道号
                    int nLaneID = msg.nLaneID;
                    System.out.println("nLaneID:" + nLaneID);
                    //事件名称
                    byte[] szName = msg.szName;
                    System.out.println("szName UTF-8:" + new String(szName,"UTF-8").trim());
                    System.out.println("szName GBK:" + new String(szName,"GBK").trim());
                    //相对事件时间戳(单位是毫秒)
                    double pts = msg.PTS;
                    System.out.println("pts:" + new Date((long) pts));
                    //UTC时间
                    NET_TIME_EX UTC = msg.UTC;
                    System.out.println("UTC:" + UTC.toStringTime());
                    //事件id
                    int nEventID = msg.nEventID;
                    System.out.println("nEventID:" + nEventID);
                    EventDto dto = new EventDto();
                    //图片保存
                    if (pBuffer != null && dwBufSize > 0 && msg.stuCommInfo.nPictureNum > 0) {
                        System.out.println(msg.stuCommInfo.nPictureNum + " pictures received!");
                        for(int i = 0; i < msg.stuCommInfo.nPictureNum; i ++){
                            String pName = System.currentTimeMillis() + "related_TrafficAccident_common_" + i + ".jpg";
                            String bigPicture = picturePath + "\\" + pName;
                            if(null != pBuffer){
                                dto.setBigPicture(StringUtils.isNotEmpty(dto.getBigPicture()) ? dto.getBigPicture() + ","+pName : ""+pName );
                            }
                            ToolKits.savePicture(pBuffer, msg.stuCommInfo.stuPicInfos[i].nOffset, msg.stuCommInfo.stuPicInfos[i].nLength, bigPicture);
                        }
                    }

                    dto.setEvent_name("路障检测");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel(nChannelID+"");
                    dto.setLane(nLaneID+"");
                    dto.setEvent_utc_time(UTC.toStringTime());
                    dto.setSzName(new String(szName,"UTF-8").trim());
                    dto.setEvent_time(DateUtil.format(new Date((long) pts), "yyyy-MM-dd HH:mm:ss.SSS"));
                    dto.setEvent_id(nEventID+"");
                    JdbcUtils.insert(dto);
                    break;
                }*/
                //交通流量事件
                case  EVENT_IVS_TRAFFIC_FLOWSTATE : {
                    System.out.println("交通流量事件, code = " + dwAlarmType);
                    try {
                        NetSDKLib.DEV_EVENT_TRAFFIC_FLOW_STATE msg = new NetSDKLib.DEV_EVENT_TRAFFIC_FLOW_STATE();
                        ToolKits.GetPointerData(pAlarmInfo, msg);
                        System.out.println("规则编号："+ msg.nRuleID);
                        // 通道号
                        int nChannelID = msg.nChannelID;
                        System.out.println("nChannelID:" + nChannelID);
                        //相对事件时间戳(单位是毫秒)
                        double pts = msg.PTS;
                        //UTC时间 事件发生时间
                        NetSDKLib.NET_TIME_EX UTC = msg.UTC;
                        System.out.println("UTC:" + UTC.toStringTime());
                        //事件id
                        int nEventID = msg.nEventID;
                        //流量状态数量
                        int nStateNum = msg.nStateNum;
                        //该事件触发的预置点
                        int nPresetID = msg.stuIntelliCommInfo.nPresetID;
                        //智能事件所属大类
                        String emClassType = EM_CLASS_TYPE.getNoteByValue(msg.stuIntelliCommInfo.emClassType);
                        //流量状态数量
                        int nStopVehiclenum = msg.nStopVehiclenum;
                        //流量状态数量
                        int nDetectionAreaVehicleNum = msg.nDetectionAreaVehicleNum;
                        System.out.println("车辆总数: "+ nDetectionAreaVehicleNum);
                        String p_Name ="";
                        System.out.println("图片, " + pBuffer);
                        //图片保存
                        if (pBuffer != null) {
                            String pName = System.currentTimeMillis() + "related_TrafficFlowState.jpg";
                            String picture = picturePath + "\\" + pName;
                            if(null != pBuffer){
                                p_Name = pName;

                            }
                            ToolKits.savePicture(pBuffer, 0, dwBufSize, picture);
                            System.out.println("图片 " + picture);
                        }
                        //车流量
                        int nums=0;
                        List<EventDto> list = new ArrayList<>();
                        List<Trajectory> list2 = new ArrayList<>();
                        List<Map<String, Object>> zblist;
                        List<Map<String, Object>> Traficlist;
                        String nLane= "";
                         String direction= "";
                         String zb1= "";
                         String zb2= "";
                         String zb3= "";
                         String zb4= "";
                         String zb5= "";
                        String zb6= "";
                        String zb7= "";
                        String cog= "";
                        String green= "";
                        String usetime="";
                        Integer size=  0;
                        Integer usetime2= 0;
                        Integer befor=0;
                        Integer total= 0;
                        Integer  delay=  0;
                        String alltime="";
                        String nLaneNo="";
                        int mnums=0;
                        int commaIndex =0;

                        for (int i = 0; i < nStateNum; i++) {
                            System.out.println(msg.stuStates[i]);
//                            //大车交通量
//                            nums+=msg.stuStates[i].nLargeVehicles;
//                            //中型车交通量
//                            nums+=msg.stuStates[i].nMediumVehicles;
//                            //小车交通量
//                            nums+=msg.stuStates[i].nSmallVehicles;
                            nums+=msg.stuStates[i].dwFlow;
                            int nLane2 = msg.stuStates[i].nLane;
                            System.out.println("车辆数:" + nums);
                            String test=Integer.toString(msg.nEventID);
                            String newtest=test.substring(3,test.length());
                            if(msg.stuStates[i].nLane!=0 && nums >0 ){
                                //交通流量事件
                                EventDto e = new EventDto();
                                e.setEvent_name("交通流量事件");
                                e.setEvent_code(nEventID+"");
                                e.setChannel(nChannelID+"");
                                e.setEvent_time(UTC.toStringTime());
                                e.setEvent_utc_time(UTC.toStringTime());
                                e.setEvent_id(nEventID+"");
                                e.setPreset_id(nPresetID+"");
                                e.setEvent_class(emClassType);
                                e.setStop_vehicle_num(nStopVehiclenum+"");
                                e.setDetection_area_vehicle_num(nDetectionAreaVehicleNum+"");
                                e.setFacePicture(p_Name);
                                //状态值
                                System.out.println("状态值 1- 流量过大 2- 流量过大恢复 3- 正常 4- 流量过小  5- 流量过小恢复 " + msg.stuStates[i].dwState);
                                e.setDwState( msg.stuStates[i].dwState+"");
                                System.out.println("车道方向信息 " + msg.stuStates[i].stTrafficFlowDir.emDrivingDir);
                                e.setEmDrivingDir(msg.stuStates[i].stTrafficFlowDir.emDrivingDir+"");
                                //平均车速
                                System.out.println("平均车速,单位km/h " + msg.stuStates[i].fAverageSpeed);
                                e.setfAverageSpeed(msg.stuStates[i].fAverageSpeed+"");

                                System.out.println("大车交通量 " + msg.stuStates[i].nLargeVehicles);
                                e.setnLargeVehicles(msg.stuStates[i].nLargeVehicles+"");

                                System.out.println("中型车交通量 " + msg.stuStates[i].nMediumVehicles);
                                e.setnMediumVehicles(msg.stuStates[i].nMediumVehicles+"");

                                System.out.println("小车交通量 " + msg.stuStates[i].nSmallVehicles);
                                e.setnSmallVehicles(msg.stuStates[i].nSmallVehicles+"");

                                System.out.println("左转： " + msg.stuStates[i].nLeftVehicles);
                                e.setnLeftVehicles(msg.stuStates[i].nLeftVehicles+"");
                                System.out.println("右转 " + msg.stuStates[i].nRightVehicles);
                                e.setnRightVehicles(msg.stuStates[i].nRightVehicles+"");
                                System.out.println("直行 " + msg.stuStates[i].nStraightVehicles);
                                e.setnStraightVehicles(msg.stuStates[i].nStraightVehicles+"");

                                e.setnUTurnVehicles( msg.stuStates[i].nUTurnVehicles+"");
                                list.add(e);
                                //车辆轨迹设置
                                for (EventDto eventDto : list) {
                                    eventDto.setState_num(nums+"");
                                    JdbcUtils.insert(eventDto);
                                }

                                try {
                                    String sql3 = "select t.nJun,t.device_address,t.nChannel,t.nLane,t.nLaneNo,t.direction,t.cog,t.size,t.usetime,t.befor,t.total,t.zb1,t.zb2,t.zb3,t.zb4,t.zb5,t.zb6,t.zb7,t.zb8,t.alltime  "
                                            + ",t.green  from zbset t where nChannel=? and zb1 is not null ";
                                    zblist = JdbcUtils.queryBean(sql3, msg.nChannelID);
                                    if (null != zblist && zblist.size() > 0) {
                                        for (int w = 0; w < zblist.size(); w++) {
                                            delay=0;
                                            nLane = zblist.get(w).get("nLane").toString() ;
                                            direction = zblist.get(w).get("direction").toString() ;
                                            zb1 = zblist.get(w).get("zb1").toString();
                                            zb2 = zblist.get(w).get("zb2").toString() ;
                                            zb3 = zblist.get(w).get("zb3").toString();
                                            zb4 = zblist.get(w).get("zb4").toString() ;
                                            zb5 = zblist.get(w).get("zb5").toString();
                                            zb6 = zblist.get(w).get("zb6").toString();
                                            zb7 = zblist.get(w).get("zb7").toString();
                                            cog = zblist.get(w).get("cog").toString() ;
                                            green = zblist.get(w).get("green").toString() ;
                                            usetime = zblist.get(w).get("usetime").toString();
                                            usetime2=new Integer(zblist.get(w).get("usetime").toString()) ;
                                            size = new Integer(zblist.get(w).get("size").toString());
                                            alltime = zblist.get(w).get("alltime").toString();
                                            befor = new Integer(zblist.get(w).get("befor").toString()) ;
                                            total = new Integer(zblist.get(w).get("total").toString());
                                            nLaneNo=zblist.get(w).get("nLaneNo").toString() ;

                                            String sql4 = "select t.nLane,t.direction,t.green from trafic t "
                                                    +"  where t.nLane='"+nLane+"' and direction='"+direction+"' "
                                                    +"  and t.green=DATE_FORMAT(DATE_ADD(STR_TO_DATE('"+green+"','%Y-%m-%d %H:%i:%s'),"
                                                    +"  INTERVAL floor(TIMESTAMPDIFF(SECOND,'"+green+"','"+UTC.toStringTime()+"')/"+alltime+")*"+alltime+" SECOND),'%Y-%m-%d %H:%i:%s') ";
                                            Traficlist = JdbcUtils.queryBean(sql4, null);
                                            if (null != Traficlist && Traficlist.size() > 0) {
                                                //不再生成軌跡
                                            }else{
                                                //生成軌跡
                                                //生成trafic
                                                String sql5 = "insert into trafic(nLane,direction,green) value ("
                                                        +"'"+nLane+"','"+direction+"',"
                                                        +"  DATE_FORMAT(DATE_ADD(STR_TO_DATE('"+green+"','%Y-%m-%d %H:%i:%s'),"
                                                        +"  INTERVAL floor(TIMESTAMPDIFF(SECOND,'"+green+"','"+UTC.toStringTime()+"')/"+alltime+")*"+alltime+""
                                                        +"  SECOND),'%Y-%m-%d %H:%i:%s')) ";

                                                JdbcUtils.insertTraFic(sql5);

                                                //限制最大過車量
                                                if(nums>total){
                                                    nums=total;
                                                }

                                                //車少情況
                                                mnums = (int)nums*size/total;

                                                for (int j = 0; j < mnums; j++) {
                                                    if(nLane.equals("LSDX-01") || nLane.equals("LSDX-02") || nLane.equals("PCXD-03") || nLane.equals("PCDX-01")){
                                                        if(direction.equals("直行")){
                                                            if(j==0){
                                                                delay=25;
                                                            }
                                                            delay=delay+(usetime2-25)/mnums;
                                                        }else{
                                                            delay=delay+(usetime2-25)/mnums;
                                                        }
                                                    }else{
                                                        delay=delay+(usetime2-2)/mnums;
                                                    }

                                                    Trajectory t = new Trajectory();
                                                    t.setTime(UTC.toStringTime());
                                                    t.setChannel(e.getChannel());
                                                    t.setOrderno("1");
                                                    t.setSog("10");
                                                    t.setTimeout("100");
                                                    t.setMmsi("100");
                                                    t.setHeading("0");
                                                    t.setImo("0");
                                                    t.setCallsign("0");
                                                    t.setInlandShipMark("false");
                                                    t.setOrdercar(j+"");
                                                    t.setState("0");

                                                    t.setName("tt");
                                                    t.setDelay(delay.toString());
                                                    t.setNlane(nLane);
                                                    t.setCog(cog);
                                                    t.setDirection(direction);
                                                    commaIndex=zb1.indexOf(',');
                                                    t.setLon(zb1.substring(0, commaIndex));
                                                    t.setLat(zb1.substring(commaIndex + 1));
                                                    t.setGreen(green);
                                                    t.setBefor(befor+"");
                                                    t.setUsetime(usetime);
                                                    t.setAlltime(alltime);
                                                    t.setnLaneNo(nLaneNo);
                                                    if(j==102){
                                                        t.setShipTypeName("面包车");
                                                        t.setLength("6");
                                                        t.setWidth("3");
                                                        t.setShipTypeClassName("中型车");
                                                    }else if(j==8){
                                                        t.setShipTypeName("公交车");
                                                        t.setLength("10");
                                                        t.setWidth("3.5");
                                                        t.setShipTypeClassName("大型车");
                                                    }else if(j==4){
                                                        t.setShipTypeName("出租车");
                                                        t.setLength("4");
                                                        t.setWidth("2");
                                                        t.setShipTypeClassName("小轿车");
                                                    }else if(j==9){
                                                        t.setShipTypeName("大货车");
                                                        t.setLength("10");
                                                        t.setWidth("3.5");
                                                        t.setShipTypeClassName("大型车");
                                                    }else{
                                                        t.setShipTypeName("私家车");
                                                        t.setLength("4");
                                                        t.setWidth("2");
                                                        t.setShipTypeClassName("小轿车");
                                                    }
                                                    list2.add(t);
                                                    Trajectory t11 = new Trajectory();

                                                    t11.setTime(t.getTime());
                                                    t11.setChannel(t.getChannel());
                                                    t11.setOrderno("2");
                                                    t11.setSog("10");
                                                    t11.setTimeout("100");
                                                    t11.setMmsi(t.getMmsi());
                                                    t11.setHeading("0");
                                                    t11.setImo("0");
                                                    t11.setCallsign("0");
                                                    t11.setInlandShipMark("false");
                                                    t11.setOrdercar(j+"");
                                                    t11.setShipTypeName(t.getShipTypeName());
                                                    t11.setLength(t.getLength());
                                                    t11.setWidth(t.getWidth());
                                                    t11.setShipTypeClassName(t.getShipTypeClassName());

                                                    t11.setName("tt");
                                                    t11.setDelay(delay.toString());
                                                    t11.setNlane(nLane);
                                                    t11.setCog(cog);
                                                    t11.setDirection(direction);
                                                    commaIndex=zb2.indexOf(',');
                                                    t11.setLon(zb2.substring(0, commaIndex));
                                                    t11.setLat(zb2.substring(commaIndex + 1));
                                                    t11.setState("0");
                                                    t11.setGreen(green);
                                                    t11.setBefor(befor+"");
                                                    t11.setUsetime(usetime);
                                                    t11.setAlltime(alltime);
                                                    t11.setnLaneNo(nLaneNo);
                                                    list2.add(t11);
                                                    Trajectory t12 = new Trajectory();

                                                    t12.setTime(t.getTime());
                                                    t12.setChannel(t.getChannel());
                                                    t12.setOrderno("3");
                                                    t12.setSog("10");
                                                    t12.setTimeout("100");
                                                    t12.setMmsi(t.getMmsi());
                                                    t12.setHeading("0");
                                                    t12.setImo("0");
                                                    t12.setCallsign("0");
                                                    t12.setInlandShipMark("false");
                                                    t12.setOrdercar(j+"");
                                                    t12.setShipTypeName(t.getShipTypeName());
                                                    t12.setLength(t.getLength());
                                                    t12.setWidth(t.getWidth());
                                                    t12.setShipTypeClassName(t.getShipTypeClassName());

                                                    t12.setName("tt");
                                                    t12.setDelay(delay.toString());
                                                    t12.setNlane(nLane);
                                                    t12.setCog(cog);
                                                    t12.setDirection(direction);
                                                    commaIndex=zb3.indexOf(',');
                                                    t12.setLon(zb3.substring(0, commaIndex));
                                                    t12.setLat(zb3.substring(commaIndex + 1));
                                                    t12.setState("0");
                                                    t12.setGreen(green);
                                                    t12.setBefor(befor+"");
                                                    t12.setUsetime(usetime);
                                                    t12.setAlltime(alltime);
                                                    t12.setnLaneNo(nLaneNo);
                                                    list2.add(t12);
                                                    Trajectory t13 = new Trajectory();

                                                    t13.setTime(t.getTime());
                                                    t13.setChannel(t.getChannel());
                                                    t13.setOrderno("4");
                                                    t13.setSog("10");
                                                    t13.setTimeout("100");
                                                    t13.setMmsi(t.getMmsi());
                                                    t13.setHeading("0");
                                                    t13.setImo("0");
                                                    t13.setCallsign("0");
                                                    t13.setInlandShipMark("false");
                                                    t13.setOrdercar(j+"");
                                                    t13.setShipTypeName(t.getShipTypeName());
                                                    t13.setLength(t.getLength());
                                                    t13.setWidth(t.getWidth());
                                                    t13.setShipTypeClassName(t.getShipTypeClassName());

                                                    t13.setName("tt");
                                                    t13.setDelay(delay.toString());
                                                    t13.setNlane(nLane);
                                                    t13.setCog(cog);
                                                    t13.setDirection(direction);
                                                    commaIndex=zb4.indexOf(',');
                                                    t13.setLon(zb4.substring(0, commaIndex));
                                                    t13.setLat(zb4.substring(commaIndex + 1));
                                                    t13.setState("0");
                                                    t13.setGreen(green);
                                                    t13.setBefor(befor+"");
                                                    t13.setUsetime(usetime);
                                                    t13.setAlltime(alltime);
                                                    t13.setnLaneNo(nLaneNo);
                                                    list2.add(t13);
                                                    Trajectory t14 = new Trajectory();

                                                    t14.setTime(t.getTime());
                                                    t14.setChannel(t.getChannel());
                                                    t14.setOrderno("5");
                                                    t14.setDirection("2");
                                                    t14.setSog("10");
                                                    t14.setTimeout("100");
                                                    t14.setMmsi(t.getMmsi());
                                                    t14.setCog("0");
                                                    t14.setHeading("0");
                                                    t14.setImo("0");
                                                    t14.setCallsign("0");
                                                    t14.setInlandShipMark("false");
                                                    t14.setNlane("2");
                                                    t14.setOrdercar(j+"");
                                                    t14.setShipTypeName(t.getShipTypeName());
                                                    t14.setLength(t.getLength());
                                                    t14.setWidth(t.getWidth());
                                                    t14.setShipTypeClassName(t.getShipTypeClassName());
                                                    t14.setState("0");

                                                    t14.setName("tt");
                                                    t14.setDelay(delay.toString());
                                                    t14.setNlane(nLane);
                                                    t14.setCog(cog);
                                                    t14.setDirection(direction);
                                                    commaIndex=zb5.indexOf(',');
                                                    t14.setLon(zb5.substring(0, commaIndex));
                                                    t14.setLat(zb5.substring(commaIndex + 1));
                                                    t14.setState("0");
                                                    t14.setGreen(green);
                                                    t14.setBefor(befor+"");
                                                    t14.setUsetime(usetime);
                                                    t14.setAlltime(alltime);
                                                    t14.setnLaneNo(nLaneNo);
                                                    list2.add(t14);
                                                    Trajectory t15 = new Trajectory();

                                                    t15.setTime(t.getTime());
                                                    t15.setChannel(t.getChannel());
                                                    t15.setOrderno("6");
                                                    t15.setDirection("2");
                                                    t15.setSog("10");
                                                    t15.setTimeout("100");
                                                    t15.setMmsi(t.getMmsi());
                                                    t15.setCog("0");
                                                    t15.setHeading("0");
                                                    t15.setImo("0");
                                                    t15.setCallsign("0");
                                                    t15.setInlandShipMark("false");
                                                    t15.setNlane("2");
                                                    t15.setOrdercar(j+"");
                                                    t15.setShipTypeName(t.getShipTypeName());
                                                    t15.setLength(t.getLength());
                                                    t15.setWidth(t.getWidth());
                                                    t15.setShipTypeClassName(t.getShipTypeClassName());
                                                    t15.setState("0");

                                                    t15.setName("tt");
                                                    t15.setDelay(delay.toString());
                                                    t15.setNlane(nLane);
                                                    t15.setCog(cog);
                                                    t15.setDirection(direction);
                                                    commaIndex=zb6.indexOf(',');
                                                    t15.setLon(zb6.substring(0, commaIndex));
                                                    t15.setLat(zb6.substring(commaIndex + 1));
                                                    t15.setState("0");
                                                    t15.setGreen(green);
                                                    t15.setBefor(befor+"");
                                                    t15.setUsetime(usetime);
                                                    t15.setAlltime(alltime);
                                                    t15.setnLaneNo(nLaneNo);
                                                    list2.add(t15);
                                                    Trajectory t16 = new Trajectory();

                                                    t16.setTime(t.getTime());
                                                    t16.setChannel(t.getChannel());
                                                    t16.setOrderno("7");
                                                    t16.setDirection("2");
                                                    t16.setSog("10");
                                                    t16.setTimeout("100");
                                                    t16.setMmsi(t.getMmsi());
                                                    t16.setCog("0");
                                                    t16.setHeading("0");
                                                    t16.setImo("0");
                                                    t16.setCallsign("0");
                                                    t16.setInlandShipMark("false");
                                                    t16.setNlane("2");
                                                    t16.setOrdercar(j+"");
                                                    t16.setShipTypeName(t.getShipTypeName());
                                                    t16.setLength(t.getLength());
                                                    t16.setWidth(t.getWidth());
                                                    t16.setShipTypeClassName(t.getShipTypeClassName());
                                                    t16.setState("0");

                                                    t16.setName("tt");
                                                    t16.setDelay(delay.toString());
                                                    t16.setNlane(nLane);
                                                    t16.setCog(cog);
                                                    t16.setDirection(direction);
                                                    commaIndex=zb7.indexOf(',');
                                                    t16.setLon(zb7.substring(0, commaIndex));
                                                    t16.setLat(zb7.substring(commaIndex + 1));
                                                    t16.setState("0");
                                                    t16.setGreen(green);
                                                    t16.setBefor(befor+"");
                                                    t16.setUsetime(usetime);
                                                    t16.setAlltime(alltime);
                                                    t16.setnLaneNo(nLaneNo);
                                                    list2.add(t16);
                                                }
                                                for (Trajectory trac : list2) {
                                                    JdbcUtils.insert(trac);
                                                }
                                                JdbcUtils.updateTrajectory();
                                            }
                                        }
                                    }
                                }catch(Exception e1) {
                                    e1.printStackTrace();
                                }finally {
                                }
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    break;
                }
                //数量统计事件
               /* case EVENT_IVS_NUMBERSTAT:
                {
                    System.out.println("数量统计事件, code = " + dwAlarmType);
                    DEV_EVENT_NUMBERSTAT_INFO msg = new DEV_EVENT_NUMBERSTAT_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 通道号
                    int nChannelID = msg.nChannelID;
                    System.out.println("nChannelID:" + nChannelID);
                    // 动作
                    int nNumber = msg.nNumber;
                    System.out.println("nNumber:" + nNumber);
                    // 动作
                    int nEnteredNumber = msg.nEnteredNumber;
                    System.out.println("nEnteredNumber:" + nEnteredNumber);
                    // 动作
                    int nExitedNumber = msg.nExitedNumber;
                    System.out.println("nExitedNumber:" + nExitedNumber);
                    // 动作
                    int emType = msg.emType;
                    System.out.println("emType:" + emType + "," + EM_NUMBER_STAT_TYPE.getNoteByValue(emType));
                    //事件名称
                    byte[] szName = msg.szName;
                    System.out.println("szName UTF-8:" + new String(szName,"UTF-8").trim());
                    System.out.println("szName GBK:" + new String(szName,"GBK").trim());
                    //相对事件时间戳(单位是毫秒)
                    double pts = msg.PTS;
                    System.out.println("pts:" + new Date((long) pts));
                    //事件id
                    int nEventID = msg.nEventID;
                    System.out.println("nEventID:" + nEventID);
//                    NET_IMAGE_INFO_EX2 pstuImageInfo = new NET_IMAGE_INFO_EX2();
//                    ToolKits.GetPointerDataToStruct(msg.pstuImageInfo, 0, pstuImageInfo);
//                    System.out.println("pstuImageInfo.nOffset:" + pstuImageInfo.nOffset);
//                    System.out.println("pstuImageInfo.nLength:" + pstuImageInfo.nLength);
                    if (pBuffer != null && dwBufSize > 0) {
                        System.out.println("basic picture received!");
                        String bigPicture = picturePath + "\\" + System.currentTimeMillis() + "related_NumberStat_basic" + ".jpg";
                        ToolKits.savePicture(pBuffer, dwBufSize, bigPicture);
                    }
//                    if (pstuImageInfo != null && pstuImageInfo.nLength > 0) {
//                        System.out.println("pstuImageInfo picture received!");
//                        String bigPicture = picturePath + "\\" + System.currentTimeMillis() + "related_NumberStat_pstuImageInfo" + ".jpg";
//                        ToolKits.savePicture(pBuffer, pstuImageInfo.nOffset, pstuImageInfo.nLength, bigPicture);
//                    }
                    EventDto dto = new EventDto();
                    dto.setEvent_name("数量统计事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel(nChannelID+"");
                    dto.setSzName(new String(msg.szName,"UTF-8").trim());
                    dto.setEvent_time(DateUtil.format(new Date((long) pts), "yyyy-MM-dd HH:mm:ss.SSS"));
                    dto.setnNumber(nNumber+"");
                    dto.setnEnteredNumber(nEnteredNumber+"");
                    dto.setnExitedNumber(nExitedNumber+"");
                    dto.setEmType(emType+"");
                    dto.setEvent_id(nEventID+"");
                    JdbcUtils.insert(dto);
                    break;
                }*/
                // 拥挤程度检测事件(对应 DEV_EVENT_CROWD_LEVEL_DETECTION_INFO)
                /* case EVENT_IVS_CROWD_LEVEL_DETECTION: {
                    DEV_EVENT_CROWD_LEVEL_DETECTION_INFO msg = new DEV_EVENT_CROWD_LEVEL_DETECTION_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    System.out.println(" 拥挤程度检测事件 时间(UTC)：" + msg.stuUTC.toStringTime() + " 通道号:" + msg.nChannelID
                            + " 事件ID:" + msg.nEventID + " 触发报警人数:" + msg.nCrowdDetectNum  + " 图片数量:" + msg.nImageInfoNum);
                    //多图
                    if(msg.nImageInfoNum > 0){
                        NET_IMAGE_INFO_EX3[] objects = new NET_IMAGE_INFO_EX3[msg.nImageInfoNum];
                        for(int i = 0; i < msg.nImageInfoNum; i ++){
                            objects[i] = new NET_IMAGE_INFO_EX3();
                        }
                        ToolKits.GetPointerDataToStructArr(msg.pstuImageInfo, objects);
                        for(int i = 0; i < msg.nImageInfoNum; i ++){
                            String bigPicture = picturePath + "\\" + "EVENT_IVS_CROWD_LEVEL_DETECTION_" + i + "_" + System.currentTimeMillis()
                                    + ".jpg";
                            System.out.println("Object[" + i + "] 偏移量:"
                                    + objects[i].nOffset + " 长度:" + objects[i].nLength + " 存储位置:" + bigPicture  );
                            ToolKits.savePicture(pBuffer, objects[i].nOffset, objects[i].nLength, bigPicture);
                        }
                    }
                    EventDto dto = new EventDto();
                    dto.setEvent_name("拥挤程度检测事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel( msg.nChannelID+"");
                    dto.setnCrowdDetectNum(msg.nCrowdDetectNum+"");
                    dto.setEvent_utc_time(msg.stuUTC.toStringTime());
                    dto.setEvent_id(msg.nEventID +"");
                    dto.setnImageInfoNum(msg.nImageInfoNum+"");
                    JdbcUtils.insert(dto);
                    break;
                }*/
                // 特殊车辆检测
                /* case EVENT_IVS_TRAFFIC_SPECIAL_VEHICLE_DETECT:
                {
                    System.out.println("特殊车辆检测, code = " + dwAlarmType);
                    DEV_EVENT_TRAFFIC_SPECIAL_VEHICLE_INFO  msg = new DEV_EVENT_TRAFFIC_SPECIAL_VEHICLE_INFO ();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 通道号
                    int nChannelID = msg.nChannelID;
                    System.out.println("nChannelID:" + nChannelID);
                    // 动作
                    int nAction = msg.nAction;
                    System.out.println("nAction:" + nAction);
                    // 规则
                    int nRuleId = msg.nRuleId;
                    System.out.println("nRuleId:" + nRuleId);
                    // 触发方式
                    int emTriggerType = msg.emTriggerType;
                    System.out.println("emTriggerType:" + emTriggerType + "," + EM_TRIGGER_TYPE.getNoteByValue(emTriggerType));
                    //事件名称
                    byte[] szName = msg.szName;
                    System.out.println("szName UTF-8:" + new String(szName,"UTF-8").trim());
                    System.out.println("szName GBK:" + new String(szName,"GBK").trim());
                    //相对事件时间戳(单位是毫秒)
                    double pts = msg.PTS;
                    System.out.println("pts:" + new Date((long) pts));
                    //事件id
                    int nEventID = msg.nEventID;
                    System.out.println("nEventID:" + nEventID);
                    //图片保存
                    if (pBuffer != null && dwBufSize > 0 && msg.stuCommInfo.nPictureNum > 0) {
                        System.out.println(msg.stuCommInfo.nPictureNum + " pictures received!");
                        for(int i = 0; i < msg.stuCommInfo.nPictureNum; i ++){
                            String bigPicture = picturePath + "\\" + System.currentTimeMillis() + "related_SpecialVehicleDetect_common_" + i + ".jpg";
                            ToolKits.savePicture(pBuffer, msg.stuCommInfo.stuPicInfos[i].nOffset, msg.stuCommInfo.stuPicInfos[i].nLength, bigPicture);
                        }
                    }
                    EventDto dto = new EventDto();
                    dto.setEvent_name("特殊车辆检测");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel(nChannelID+"");
                    dto.setnAction(nAction+"");
                    dto.setRule_Id(nRuleId+"");
                    dto.setEmTriggerType(emTriggerType+"");
                    dto.setEvent_id(nEventID+"");
                    dto.setSzName(new String(szName,"UTF-8").trim());
                    dto.setEvent_time(DateUtil.format(new Date((long) pts), "yyyy-MM-dd HH:mm:ss.SSS"));
                    JdbcUtils.insert(dto);
                    break;
                }*/
                // 占用应急车道事件
               /* case EVENT_IVS_TRAFFIC_VEHICLE_IN_EMERGENCY_LANE:
                {
                    System.out.println("占用应急车道事件, code = " + dwAlarmType);
                    DEV_EVENT_TRAFFIC_VEHICLE_IN_EMERGENCY_LANE_INFO  msg = new DEV_EVENT_TRAFFIC_VEHICLE_IN_EMERGENCY_LANE_INFO ();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 通道号
                    int nChannelID = msg.nChannelID;
                    System.out.println("nChannelID:" + nChannelID);
                    // 动作
                    int nAction = msg.nAction;
                    System.out.println("nAction:" + nAction);
                    //事件名称
                    byte[] szName = msg.szName;
                    System.out.println("szName UTF-8:" + new String(szName,"UTF-8").trim());
                    System.out.println("szName GBK:" + new String(szName,"GBK").trim());
                    //相对事件时间戳(单位是毫秒)
                    double pts = msg.PTS;
                    System.out.println("pts:" + new Date((long) pts));
                    //事件id
                    int nEventID = msg.nEventID;
                    System.out.println("nEventID:" + nEventID);
                    //图片保存
                    if (pBuffer != null && dwBufSize > 0 && msg.stuCommInfo.nPictureNum > 0) {
                        System.out.println(msg.stuCommInfo.nPictureNum + " pictures received!");
                        for(int i = 0; i < msg.stuCommInfo.nPictureNum; i ++){
                            String bigPicture = picturePath + "\\" + System.currentTimeMillis() + "related_VehicleInEmergency_common_" + i + ".jpg";
                            ToolKits.savePicture(pBuffer, msg.stuCommInfo.stuPicInfos[i].nOffset, msg.stuCommInfo.stuPicInfos[i].nLength, bigPicture);
                        }
                    }
                    EventDto dto = new EventDto();
                    dto.setEvent_name("占用应急车道事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel(nChannelID+"");
                    dto.setnAction(nAction+"");
                    dto.setEvent_id(nEventID+"");
                    dto.setSzName(new String(szName,"UTF-8").trim());
                    dto.setEvent_time(DateUtil.format(new Date((long) pts), "yyyy-MM-dd HH:mm:ss.SSS"));
                    JdbcUtils.insert(dto);
                    break;

                }*/
                // 违章变道
               /* case EVENT_IVS_TRAFFIC_CROSSLANE:
                {
                    System.out.println("违章变道, code = " + dwAlarmType);
                    EventDto dto = new EventDto();
                    dto.setEvent_name("违章变道");
                    dto.setEvent_code(dwAlarmType+"");
                    JdbcUtils.insert(dto);
                    break;
                }*/
                // 火警事件(对应 DEV_EVENT_FIRE_INFO)
                /*case EVENT_IVS_FIREDETECTION: {
                    DEV_EVENT_FIRE_INFO msg = new DEV_EVENT_FIRE_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 全景广角图
                    if (msg.stuSceneImage != null && msg.stuSceneImage.nLength > 0) {
                        String bigPicture = picturePath + "\\" + "EVENT_IVS_FIREDETECTION" + System.currentTimeMillis()
                                + ".jpg";
                        ToolKits.savePicture(pBuffer, msg.stuSceneImage.nOffSet, msg.stuSceneImage.nLength, bigPicture);
                    }
                    System.out.println(" 火警事件 时间(UTC)：" + msg.UTC + " 通道号:" + msg.nChannelID + " 开始时间:"
                            + msg.stuObject.stuStartTime + " 结束时间:" + msg.stuObject.stuEndTime + " 事件ID:" + msg.nEventID
                            + " 抓拍过程:" + msg.emCaptureProcess);
                    EventDto dto = new EventDto();
                    dto.setEvent_name("火警事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setEvent_utc_time(msg.UTC.toStringTime());
                    dto.setChannel(msg.nChannelID+"");
                    dto.setStuStartTime(msg.stuObject.stuStartTime+"");
                    dto.setStuEndTime(msg.stuObject.stuEndTime+"");
                    dto.setEvent_id(msg.nEventID+"");
                    dto.setEmCaptureProcess(msg.emCaptureProcess+"");
                    JdbcUtils.insert(dto);
                    break;
                }*/
                // 烟雾报警事件(对应 DEV_EVENT_SMOKE_INFO)
               /* case EVENT_IVS_SMOKEDETECTION: {
                    DEV_EVENT_SMOKE_INFO msg = new DEV_EVENT_SMOKE_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 全景广角图
                    if (msg.stuSceneImage != null && msg.stuSceneImage.nLength > 0) {
                        String bigPicture = picturePath + "\\" + "EVENT_IVS_SMOKEDETECTION" + System.currentTimeMillis()
                                + ".jpg";
                        ToolKits.savePicture(pBuffer, msg.stuSceneImage.nOffSet, msg.stuSceneImage.nLength, bigPicture);
                    }
                    System.out.println(" 烟雾报警事件 时间(UTC)：" + msg.UTC + " 通道号:" + msg.nChannelID + " 开始时间:"
                            + msg.stuObject.stuStartTime + " 结束时间:" + msg.stuObject.stuEndTime + " 事件ID:" + msg.nEventID);
                    EventDto dto = new EventDto();
                    dto.setEvent_name("烟雾报警事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setEvent_utc_time(msg.UTC.toStringTime());
                    dto.setChannel(msg.nChannelID+"");
                    dto.setStuStartTime(msg.stuObject.stuStartTime+"");
                    dto.setStuEndTime(msg.stuObject.stuEndTime+"");
                    dto.setEvent_id(msg.nEventID+"");
                    JdbcUtils.insert(dto);
                    break;
                }*/
                // 区域入侵
                /*case EVENT_IVS_CROSSREGIONDETECTION:
                {
                    System.out.println("区域入侵, code = " + dwAlarmType);
                    EventDto dto = new EventDto();
                    dto.setEvent_name("区域入侵");
                    dto.setEvent_code(dwAlarmType+"");
                    JdbcUtils.insert(dto);
                    break;
                }*/
                //交通车辆清洁度检测事件检测
                /*case EVENT_IVS_TRAFFIC_VEHICLE_CLEANLINESS : {
                    EventDto dto = new EventDto();
                    System.out.println("交通车辆清洁度检测事件检测, code = " + dwAlarmType);
                    DEV_EVENT_TRAFFIC_VEHICLE_CLEANLINESS_INFO msg = new DEV_EVENT_TRAFFIC_VEHICLE_CLEANLINESS_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 通道号
                    int nChannelID = msg.nChannelID;
                    System.out.println("nChannelID:" + nChannelID);
                    //事件名称
                    byte[] szName = msg.szName;
                    System.out.println("szName:" + new String(szName).trim());
                    //相对事件时间戳(单位是毫秒)
                    double pts = msg.PTS;
                    System.out.println("pts:" + new Date((long) pts));
                    //UTC时间
                    NET_TIME_EX UTC = msg.UTC;
                    System.out.println("UTC:" + UTC.toStringTime());
                    //事件id
                    int nEventID = msg.nEventID;
                    System.out.println("nEventID:" + nEventID);
                    //RuleId
                    int nRuleId = msg.nRuleId;
                    System.out.println("nRuleId:" + nRuleId);
                    //事件id
                    int objObjectID = msg.stuObject.nObjectID;
                    System.out.println("ObjObjectID:" + objObjectID);
                    //事件id
                    String objName = new String(msg.stuObject.szObjectType).trim();
                    System.out.println("objName:" + objName);
                    //图片
                    NetSDKLib.NET_PIC_INFO stPicInfo = msg.stuObject.stPicInfo;
//                    System.out.println("stPicInfo:" + stPicInfo.toString());
                    //图片保存
                    if (stPicInfo != null && stPicInfo.dwFileLenth > 0) {
                        String picture = picturePath + "/" + System.currentTimeMillis() + "related_EVENT_IVS_TRAFFIC_VEHICLE_CLEANLINESS.jpg";
                        System.out.println("Picture saved, the path is  " + picture);
                        ToolKits.savePicture(pBuffer, stPicInfo.dwOffSet, stPicInfo.dwFileLenth, picture);
                    }
                    //事件id
                    int emTriggerType = msg.emTriggerType;
                    System.out.println("emTriggerType:" + emTriggerType);
                    //事件id
                    int nCleanValue = msg.nCleanValue;
                    System.out.println("nCleanValue:" + nCleanValue);

                    dto.setEvent_name("交通车辆清洁度检测事件检测");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel(nChannelID+"");
                    dto.setSzName(new String(msg.szName,"UTF-8").trim());
                    dto.setEvent_time(DateUtil.format(new Date((long) pts), "yyyy-MM-dd HH:mm:ss.SSS"));
                    dto.setEvent_utc_time(UTC.toStringTime());
                    dto.setEvent_id(nEventID+"");
                    dto.setRule_Id(nRuleId+"");
                    dto.setObject_id(objObjectID+"");
                    dto.setObj_name(objName+"");
                    dto.setEmTriggerType(emTriggerType+"");
                    dto.setClean_value(nCleanValue+"");
                    JdbcUtils.insert(dto);
                    break;
                }*/
                //渣土车未遮盖载货检测事件
                /*  case EVENT_IVS_DREGS_UNCOVERED : {
                    EventDto dto = new EventDto();
                    System.out.println("渣土车未遮盖载货检测事件, code = " + dwAlarmType);
                    dto.setEvent_name("渣土车未遮盖载货检测事件");
                    dto.setEvent_code(dwAlarmType+"");
                    DEV_EVENT_DREGS_UNCOVERED_INFO msg = new DEV_EVENT_DREGS_UNCOVERED_INFO();

                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 通道号
                    int nChannelID = msg.nChannelID;
                    System.out.println("nChannelID:" + nChannelID);
                    dto.setChannel(nChannelID+"");
                    //事件名称
                    byte[] szName = msg.szName;
                    System.out.println("szName:" + new String(szName));
                    dto.setSzName( new String(msg.szName,"UTF-8").trim());
                    //相对事件时间戳(单位是毫秒)
                    double pts = msg.PTS;
                    System.out.println("pts:" + new Date((long) pts));
                    dto.setEvent_time(DateUtil.format(new Date((long) pts), "yyyy-MM-dd HH:mm:ss.SSS"));
                    //UTC时间
                    NET_TIME_EX UTC = msg.UTC;
                    System.out.println("UTC:" + UTC.toStringTime());
                    dto.setEvent_utc_time(UTC.toStringTime());
                    //事件id
                    int nEventID = msg.nEventID;
                    System.out.println("nEventID:" + nEventID);
                    dto.setEvent_id(nEventID+"");
                    //智能事件所属大类
                    int ClassType = msg.emClassType;
                    System.out.println("emClassType:" + EM_CLASS_TYPE.getNoteByValue(ClassType));
                    dto.setEvent_class(ClassType+"");
                    //检测区域,[0,8191]
                    int nDetectRegionNum = msg.nDetectRegionNum;
                    System.out.println("nDetectRegionNum:" + nDetectRegionNum);
                    dto.setRegion(nDetectRegionNum+"");
                    //事件对应文件信息
                    String stuDetectRegions = "";
                    NetSDKLib.NET_POINT[] stuDetectRegion = msg.stuDetectRegion;
                    for(int i = 0; i < NET_MAX_DETECT_REGION_NUM; i ++){
                        System.out.println("stuDetectRegion[" + i + "]:" + stuDetectRegion[i].toString());
                        stuDetectRegions = stuDetectRegions + stuDetectRegion[i].toString()+",";
                    }
                    dto.setEvent_code(stuDetectRegions);
                    //渣土车车辆信息
                    DREGS_UNCOVERED_VEHICLE_INFO stuVehicleInfo = msg.stuVehicleInfo;
                    System.out.println("szPlateNumber:" + new String(stuVehicleInfo.szPlateNumber).trim());
                    System.out.println("stuBoundingBox:" + stuVehicleInfo.stuBoundingBox.toString());
                    //dto.setStu_Vehicle_Info(new String(stuVehicleInfo.szPlateNumber).trim()+","+stuVehicleInfo.stuBoundingBox.toString());
                    dto.setStu_Vehicle_Info(new String(stuVehicleInfo.szPlateNumber).trim());
                    //图片保存
                    if (pBuffer != null) {
                        String picture = picturePath + "/" + System.currentTimeMillis() + "related_EVENT_IVS_DREGS_UNCOVERED.jpg";
                        ToolKits.savePicture(pBuffer, 0, dwBufSize, picture);
                    }
                    JdbcUtils.insert(dto);
                    break;
                }*/
                //安全帽检测事件
                /*case  EVENT_IVS_HELMET_DETECTION : {
                    System.out.println("安全帽检测事件, code = " + dwAlarmType);

                    DEV_EVENT_HELMET_DETECTION_INFO msg = new DEV_EVENT_HELMET_DETECTION_INFO();

                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 通道号
                    int nChannelID = msg.nChannelID;
                    System.out.println("nChannelID:" + nChannelID);
                    // 动作
                    int nAction = msg.nAction;
                    System.out.println("nAction:" + nAction);
                    //事件名称
                    byte[] szName = msg.szName;
                    System.out.println("szName UTF-8:" + new String(szName,"UTF-8").trim());
                    System.out.println("szName GBK:" + new String(szName,"GBK").trim());
                    //相对事件时间戳(单位是毫秒)
                    double pts = msg.PTS;
                    System.out.println("pts:" + new Date((long) pts));
                    //UTC时间
                    NET_TIME_EX UTC = msg.UTC;
                    System.out.println("UTC:" + UTC.toStringTime());
                    //事件类型
                    String emClassType = EM_CLASS_TYPE.getNoteByValue(msg.emClassType);
                    System.out.println("emClassType:" + emClassType);
                    //事件id
                    int nEventID = msg.nEventID;
                    System.out.println("nEventID:" + nEventID);
                    //规则编号
                    int nRuleID = msg.nRuleID;
                    System.out.println("nRuleID:" + nRuleID);
                    //目标ID
                    int nObjectID = msg.nObjectID;
                    System.out.println("nObjectID:" + nObjectID);
                    //触发事件类型
                    String emHelmetEventType = EM_HELMET_EVENT_TYPE.getNoteByValue(msg.emHelmetEventType);
                    System.out.println("emHelmetEventType:" + emHelmetEventType);
                    //事件对应文件信息
                    NetSDKLib.NET_EVENT_FILE_INFO stuFileInfo = msg.stuFileInfo;
                    System.out.println("stuFileInfo:" + stuFileInfo.toString());
                    //图片保存
                    if (msg != null) {
                        String picture = picturePath + "/" + System.currentTimeMillis() + "related_HelmetHuman" + msg.stuHumanImage.nIndexInData + ".jpg";
                        System.out.println("Picture saved, the path is  " + picture);
                        ToolKits.savePicture(pBuffer, msg.stuHumanImage.nOffSet, msg.stuHumanImage.nLength , picture);
                    }
                    //图片保存
                    if (msg != null) {
                        String picture = picturePath + "/" + System.currentTimeMillis() + "related_HelmetScene" + msg.stuSceneImage.nIndexInData + ".jpg";
                        System.out.println("Picture saved, the path is  " + picture);
                        ToolKits.savePicture(pBuffer, msg.stuSceneImage.nOffSet, msg.stuSceneImage.nLength , picture);
                    }
                    EventDto dto = new EventDto();
                    dto.setEvent_name("安全帽检测事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel(nChannelID+"");
                    dto.setSzName(new String(msg.szName,"UTF-8").trim());
                    dto.setEvent_time(DateUtil.format(new Date((long) pts), "yyyy-MM-dd HH:mm:ss.SSS"));
                    dto.setEvent_utc_time(UTC.toStringTime());
                    dto.setEvent_id(nEventID+"");
                    dto.setRule_Id(nRuleID+"");
                    dto.setObject_id(nObjectID+"");
                    dto.setEmTriggerType(emHelmetEventType+"");
                    dto.setEvent_content(stuFileInfo.toString());
                    JdbcUtils.insert(dto);
                    break;
                }*/
                //作业统计事件
                /*case  EVENT_IVS_WORKSTATDETECTION : {
                    System.out.println("作业统计事件, code = " + dwAlarmType);

                    DEV_EVENT_WORKSTATDETECTION_INFO msg = new DEV_EVENT_WORKSTATDETECTION_INFO();

                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 通道号
                    int nChannelID = msg.nChannelID;
                    System.out.println("nChannelID:" + nChannelID);
                    // 动作
                    int nAction = msg.nAction;
                    System.out.println("nAction:" + nAction);
                    //事件名称
                    byte[] szName = msg.szName;
                    System.out.println("szName UTF-8:" + new String(szName,"UTF-8").trim());
                    System.out.println("szName GBK:" + new String(szName,"GBK").trim());
                    //相对事件时间戳(单位是毫秒)
                    double pts = msg.PTS;
                    System.out.println("pts:" + new Date((long) pts));
                    //UTC时间
                    NET_TIME_EX UTC = msg.UTC;
                    System.out.println("UTC:" + UTC.toStringTime());
                    //事件类型
                    String emClassType = EM_CLASS_TYPE.getNoteByValue(msg.emClassType);
                    System.out.println("emClassType:" + emClassType);
                    //事件id
                    int nEventID = msg.nEventID;
                    System.out.println("nEventID:" + nEventID);
                    //规则编号
                    int nRuleID = msg.nRuleID;
                    System.out.println("nRuleID:" + nRuleID);
                    //目标ID
                    int nObjectID = msg.nObjectID;
                    System.out.println("nObjectID:" + nObjectID);
                    //作业行为状态个数
                    int nWorkActionNum = msg.nWorkActionNum;
                    System.out.println("nWorkActionNum:" + nWorkActionNum);
                    //作业行为状态信息
                    String nWorkAction = "";
                    for(int i = 0; i < nWorkActionNum; i ++){
                        System.out.println("emWorkAction[" + i + "]:" + EM_WORKACTION_STATE.getNoteByValue(msg.emWorkAction[i]));
                        nWorkAction = nWorkAction + EM_WORKACTION_STATE.getNoteByValue(msg.emWorkAction[i]) + ",";
                    }
                    //触发事件类型
                    String emRuleType = EM_WORKSTATDETECTION_TYPE.getNoteByValue(msg.emRuleType);
                    System.out.println("emRuleType:" + emRuleType);
                    //图片保存
                    if (msg != null) {
                        String picture = picturePath + "/" + System.currentTimeMillis() + "related_WorkStateScene" + msg.stuSceneImage.nIndexInData + ".jpg";
                        System.out.println("Picture saved, the path is  " + picture);
                        ToolKits.savePicture(pBuffer, msg.stuSceneImage.nOffSet, msg.stuSceneImage.nLength , picture);
                    }
                    EventDto dto = new EventDto();
                    dto.setEvent_name("作业统计事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel(nChannelID+"");
                    dto.setSzName(new String(msg.szName,"UTF-8").trim());
                    dto.setEvent_time(DateUtil.format(new Date((long) pts), "yyyy-MM-dd HH:mm:ss.SSS"));
                    dto.setEvent_utc_time(UTC.toStringTime());
                    dto.setEvent_id(nEventID+"");
                    dto.setRule_Id(nRuleID+"");
                    dto.setObject_id(nObjectID+"");
                    dto.setnAction(nAction+"");
                    dto.setnWorkActionNum(nWorkActionNum+"");
                    dto.setnWorkAction(nWorkAction);
                    dto.setEmTriggerType(emRuleType+"");
                    JdbcUtils.insert(dto);
                    break;
                }*/
                // 目标识别事件
               /* case EVENT_IVS_FACERECOGNITION:
                {
                    System.out.println("目标识别事件, code = " + dwAlarmType);
                    NetSDKLib.DEV_EVENT_FACERECOGNITION_INFO msg = new NetSDKLib.DEV_EVENT_FACERECOGNITION_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    System.out.println("szVideoPath : " + new String(msg.szVideoPath).trim() + "\n" );
                    EventDto dto = new EventDto();
                    dto.setEvent_name("目标识别事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setSzVideoPath(new String(msg.szVideoPath).trim());
                    JdbcUtils.insert(dto);
                    break;

                }*/
                ///<  立体视觉区域内人数统计事件
               /* case EVENT_IVS_MAN_NUM_DETECTION:
                {
                    NetSDKLib.DEV_EVENT_MANNUM_DETECTION_INFO msg = new NetSDKLib.DEV_EVENT_MANNUM_DETECTION_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    System.out.println(" 立体视觉区域内人数统计事件 时间(UTC)：" + msg.UTC + " 通道号:" + msg.nChannelID +
                            " 区域人员列表数量:" + msg.nManListCount + " 人员身高:" + msg.stuManList[0].nStature);
                    EventDto dto = new EventDto();
                    dto.setEvent_name("立体视觉区域内人数统计事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setEvent_utc_time(msg.UTC.toStringTime());
                    dto.setChannel(msg.nChannelID+"");
                    dto.setnManListCount(msg.nManListCount+"");
                    dto.setEvent_id(msg.nEventID+"");
                    dto.setnStature(msg.stuManList[0].nStature+"");
                    JdbcUtils.insert(dto);
                    break;
                }*/
                ///< 物品遗留事件
               /* case EVENT_IVS_LEFTDETECTION:
                {
                    NetSDKLib.DEV_EVENT_LEFT_INFO msg = new NetSDKLib.DEV_EVENT_LEFT_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    System.out.println("物品遗留事件 时间(UTC)：" + msg.UTC + " 开始时间:" + msg.stuObject.stuStartTime + " 结束时间:" + msg.stuObject.stuEndTime
                            + " 事件触发的预置点号:" + msg.nPreserID + " 事件触发的预置名称:" + new String(msg.szPresetName));
                    EventDto dto = new EventDto();
                    dto.setEvent_name("物品遗留事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setEvent_utc_time(msg.UTC.toStringTime());
                    dto.setChannel(msg.nChannelID+"");
                    dto.setnPreserId( msg.nPreserID +"");
                    dto.setEvent_id(msg.nEventID+"");
                    dto.setSzPresetName(new String(msg.szPresetName));
                    dto.setStuStartTime(msg.stuObject.stuStartTime+"");
                    dto.setStuEndTime(msg.stuObject.stuEndTime+"");
                    JdbcUtils.insert(dto);
                    break;
                }*/
                ///< 物品搬移事件
               /* case EVENT_IVS_TAKENAWAYDETECTION:
                {
                    NetSDKLib.DEV_EVENT_TAKENAWAYDETECTION_INFO msg = new NetSDKLib.DEV_EVENT_TAKENAWAYDETECTION_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    System.out.println("物品搬移事件 时间(UTC)：" + msg.UTC + " 通道号:" + msg.nChannelID + " 开始时间:" + msg.stuObject.stuStartTime + " 结束时间:" + msg.stuObject.stuEndTime
                            + " 事件触发的预置点号:" + msg.nPreserID + " 事件触发的预置名称:" + new String(msg.szPresetName));
                    EventDto dto = new EventDto();
                    dto.setEvent_name("物品搬移事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setEvent_utc_time(msg.UTC.toStringTime());
                    dto.setChannel(msg.nChannelID+"");
                    dto.setnPreserId( msg.nPreserID +"");
                    dto.setEvent_id(msg.nEventID+"");
                    dto.setSzPresetName(new String(msg.szPresetName));
                    dto.setStuStartTime(msg.stuObject.stuStartTime+"");
                    dto.setStuEndTime(msg.stuObject.stuEndTime+"");
                    JdbcUtils.insert(dto);
                    break;
                }*/
                ///< 交通手动抓图事件
              /*  case EVENT_IVS_TRAFFIC_MANUALSNAP:
                {
                    NetSDKLib.DEV_EVENT_TRAFFIC_MANUALSNAP_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_MANUALSNAP_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    System.out.println("交通手动抓图事件 时间(UTC)：" + msg.UTC + " 通道号:" + msg.nChannelID + " 开始时间:" + msg.stuObject.stuStartTime + " 结束时间:" + msg.stuObject.stuEndTime
                            + " 事件名称:" + msg.szName);
                    System.out.println("停车位数据信息个数：" + msg.nParkingInfoNum);
                    List<Map<String,Object>> list = new ArrayList<>();
                    for(int i = 0; i < msg.nParkingInfoNum; i ++){
                        Map<String,Object> map = new HashMap<>();
                        System.out.println("stuParkingInfo["+i+"].nChannel = " + msg.stuParkingInfo[i].nChannel);
                        System.out.println("stuParkingInfo["+i+"].nStatus = " + msg.stuParkingInfo[i].nStatus);
                        System.out.println("stuParkingInfo["+i+"].szParkingNo = [GBK]" + new String(msg.stuParkingInfo[i].szParkingNo,"GBK").trim() + ",[UTF-8]" + new String(msg.stuParkingInfo[i].szParkingNo,"UTF-8").trim() );
                        System.out.println("stuParkingInfo["+i+"].szPlateNumber = [GBK]" + new String(msg.stuParkingInfo[i].szPlateNumber,"GBK").trim() + ",[UTF-8]" + new String(msg.stuParkingInfo[i].szPlateNumber,"UTF-8").trim());
                        map.put("nChannel",msg.stuParkingInfo[i].nChannel);
                        map.put("nStatus",msg.stuParkingInfo[i].nStatus);
                        map.put("szParkingNo",new String(msg.stuParkingInfo[i].szParkingNo,"GBK").trim() + ",[UTF-8]" + new String(msg.stuParkingInfo[i].szParkingNo,"UTF-8").trim() );
                        map.put("szPlateNumber",new String(msg.stuParkingInfo[i].szPlateNumber,"GBK").trim() + ",[UTF-8]" + new String(msg.stuParkingInfo[i].szPlateNumber,"UTF-8").trim());
                        list.add(map);
                    }

                    EventDto dto = new EventDto();
                    dto.setEvent_name("交通手动抓图事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setEvent_utc_time(msg.UTC.toStringTime());
                    dto.setChannel(msg.nChannelID+"");
                    dto.setnParkingInfoNum(JSON.toJSONString(list));
                    dto.setEvent_id(msg.nEventID+"");
                    dto.setStuStartTime(msg.stuObject.stuStartTime+"");
                    dto.setStuEndTime(msg.stuObject.stuEndTime+"");
                    dto.setSzName(new String(msg.szName,"UTF-8").trim());
                    JdbcUtils.insert(dto);
                    break;
                }*/
                ///< 温度报警事件
                /*case EVENT_IVS_TEMPERATURE_ALARM:
                {
                    NET_DEV_EVENT_TEMPERATURE_ALARM_INFO msg = new NET_DEV_EVENT_TEMPERATURE_ALARM_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    System.out.println("温度报警事件 时间(UTC)：" + msg.stuUTC.toStringTime() + " 通道号:" + msg.nChannelID
                            + " 事件名称:" + msg.szName);
                    System.out.println("GPS信息：");
                    System.out.println("stuParkingInfo.longitude = " + msg.stuGPS.longitude);
                    System.out.println("stuParkingInfo.latidude = " + msg.stuGPS.latidude);
                    System.out.println("stuParkingInfo.height = " + msg.stuGPS.height);
                    System.out.println("stuParkingInfo.angle = " + msg.stuGPS.angle);
                    EventDto dto = new EventDto();
                    dto.setEvent_name("温度报警事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setEvent_utc_time(msg.stuUTC.toStringTime());
                    dto.setChannel(msg.nChannelID+"");
                    dto.setSzName(new String(msg.szName,"UTF-8").trim());
                    dto.setLongitude( msg.stuGPS.longitude+"");
                    dto.setLatidude(msg.stuGPS.latidude+"");
                    dto.setHeight( msg.stuGPS.height+"");
                    dto.setAngle(msg.stuGPS.angle+"");
                    JdbcUtils.insert(dto);
                    break;
                }*/
                // 压线检测
               /* case EVENT_IVS_TRAFFIC_OVERLINE:
                {
                    System.out.println("压线检测, code = " + dwAlarmType);
                    EventDto dto = new EventDto();
                    dto.setEvent_name("压线检测");
                    dto.setEvent_code(dwAlarmType+"");
                    JdbcUtils.insert(dto);
                    break;
                }*/
                // 超速检测
              /*  case EVENT_IVS_TRAFFIC_OVERSPEED:
                {
                    System.out.println("超速检测, code = " + dwAlarmType);
                    EventDto dto = new EventDto();
                    dto.setEvent_name("超速检测");
                    dto.setEvent_code(dwAlarmType+"");
                    JdbcUtils.insert(dto);
                    break;
                }*/
                // 低速检测
               /* case EVENT_IVS_TRAFFIC_UNDERSPEED:
                {
                    System.out.println("低速检测, code = " + dwAlarmType);
                    EventDto dto = new EventDto();
                    dto.setEvent_name("低速检测");
                    dto.setEvent_code(dwAlarmType+"");
                    JdbcUtils.insert(dto);
                    break;
                }*/
                ///<  安全帽检测事件
              /*  case EVENT_IVS_WORKCLOTHES_DETECT:
                {
                    System.out.println("工装检测事件, code = " + dwAlarmType);
                    NetSDKLib.DEV_EVENT_WORKCLOTHES_DETECT_INFO msg = new NetSDKLib.DEV_EVENT_WORKCLOTHES_DETECT_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 通道号
                    int nChannelID = msg.nChannelID;
                    System.out.println("nChannelID:" + nChannelID);
                    // 动作
                    int nAction = msg.nAction;
                    System.out.println("nAction:" + nAction);
                    //事件名称
                    byte[] szName = msg.szName;
                    System.out.println("szName UTF-8:" + new String(szName,"UTF-8").trim());
                    System.out.println("szName GBK:" + new String(szName,"GBK").trim());
                    //相对事件时间戳(单位是毫秒)
                    double pts = msg.PTS;
                    System.out.println("pts:" + new Date((long) pts));
                    //UTC时间
                    NetSDKLib.NET_TIME_EX UTC = msg.UTC;
                    System.out.println("UTC:" + UTC.toStringTime());
                    //事件类型
                    String emClassType = EM_CLASS_TYPE.getNoteByValue(msg.emClassType);
                    System.out.println("emClassType:" + emClassType);
                    //事件id
                    int nEventID = msg.nEventID;
                    System.out.println("nEventID:" + nEventID);
                    if (msg.stuSceneImage != null && msg.stuSceneImage.nLength > 0) {
                        String bigPicture = picturePath + "\\" + System.currentTimeMillis() + "related_WorkClothes" + msg.stuSceneImage.nIndexInData + ".jpg";
                        ToolKits.savePicture(pBuffer, msg.stuSceneImage.nOffSet, msg.stuSceneImage.nLength, bigPicture);
                        if (msg.stuHumanImage != null && msg.stuHumanImage.nLength > 0) {
                            String smallPicture = picturePath + "\\" + System.currentTimeMillis() + "related_WorkClothesSmall" + msg.stuSceneImage.nIndexInData + "small.jpg";
                            ToolKits.savePicture(pBuffer, msg.stuHumanImage.nOffSet, msg.stuHumanImage.nLength, smallPicture);
                        }
                    }
                    System.out.println(" 安全帽检测事件(UTC)：" + msg.UTC + " 通道号:" + msg.nChannelID + " 图片数量:" + msg.nImageInfoNum);
                    if(msg.nImageInfoNum > 0){
                        for(int i = 0; i < msg.nImageInfoNum; i ++){
                            System.out.println("pstuImageInfo picture received!");
                            String bigPicture = picturePath + "\\" + System.currentTimeMillis() + "WORKCLOTHES_DETECT_" + i + ".jpg";
                            ToolKits.savePicture(pBuffer, msg.stuImageInfo[i].nOffset, msg.stuImageInfo[i].nLength, bigPicture);
                        }
                    }
                    EventDto dto = new EventDto();
                    dto.setEvent_name("工装检测事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel(nChannelID+"");
                    dto.setnAction(nAction+"");
                    dto.setEvent_utc_time( UTC.toStringTime());
                    dto.setEvent_class(emClassType);
                    dto.setEvent_id(nEventID+"");
                    dto.setSzName(new String(szName,"UTF-8").trim());
                    dto.setEvent_time(DateUtil.format(new Date((long) pts), "yyyy-MM-dd HH:mm:ss.SSS"));
                    JdbcUtils.insert(dto);
                    break;
                }*/
                // 异常奔跑事件(对应 DEV_EVENT_ABNORMALRUNDETECTION_INFO)
                /*case EVENT_IVS_ABNORMALRUNDETECTION: {
                    DEV_EVENT_ABNORMALRUNDETECTION_INFO msg = new DEV_EVENT_ABNORMALRUNDETECTION_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    if (pBuffer != null && dwBufSize > 0) {
                        System.out.println("basic picture received!");
                        String bigPicture = picturePath + "\\" + System.currentTimeMillis() + "ABNORMAL_RUN_DETECTION" + ".jpg";
                        ToolKits.savePicture(pBuffer, dwBufSize, bigPicture);
                    }
                    System.out.println("异常奔跑事件 时间(UTC)：" + msg.UTC + " 通道号:" + msg.nChannelID + " 开始时间:" + msg.stuObject.stuStartTime + " 结束时间:" + msg.stuObject.stuEndTime
                            + " 物体运动速度:" + msg.dbSpeed + " km/h " + " 触发速度:" + msg.dbTriggerSpeed + " km/h " + " 异常奔跑类型(0-快速奔跑, 1-突然加速, 2-突然减速):" + msg.bRunType + " 图片数量:" + msg.nImageInfoNum);
                    if(msg.nImageInfoNum > 0){
                        NET_IMAGE_INFO_EX2[] pstuImageInfo = new NET_IMAGE_INFO_EX2[msg.nImageInfoNum];
                        for(int i = 0; i < msg.nImageInfoNum; i ++){
                            pstuImageInfo[i] = new NET_IMAGE_INFO_EX2();
                        }
                        ToolKits.GetPointerDataToStructArr(msg.pstuImageInfo, pstuImageInfo);
                        for(int i = 0; i < msg.nImageInfoNum; i ++){
                            System.out.println("pstuImageInfo picture received!");
                            String bigPicture = picturePath + "\\" + System.currentTimeMillis() + "ABNORMAL_RUN_DETECTION_" + i + ".jpg";
                            ToolKits.savePicture(pBuffer, pstuImageInfo[i].nOffset, pstuImageInfo[i].nLength, bigPicture);
                        }
                    }
                    EventDto dto = new EventDto();
                    dto.setEvent_name("异常奔跑事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel( msg.nChannelID+"");
                    dto.setStuStartTime(msg.stuObject.stuStartTime+"");
                    dto.setEvent_utc_time(msg.UTC.toStringTime());
                    dto.setStuEndTime(msg.stuObject.stuEndTime+"");
                    dto.setDbSpeed(msg.dbSpeed + " km/h ");
                    dto.setDbTriggerSpeed(msg.dbTriggerSpeed + " km/h ");
                    dto.setbRunType(msg.bRunType+"");
                    dto.setnImageInfoNum(msg.nImageInfoNum+"");
                    JdbcUtils.insert(dto);
                    break;
                }*/
                // 物品拿取检测事件(对应 DEV_EVENT_OBJECT_REMOVAL_DETECTION_INFO)
              /*  case EVENT_IVS_OBJECT_REMOVAL_DETECTION: {
                    DEV_EVENT_OBJECT_REMOVAL_DETECTION_INFO msg = new DEV_EVENT_OBJECT_REMOVAL_DETECTION_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 全景广角图
                    if (msg.stuSceneImage != null && msg.stuSceneImage.nLength > 0) {
                        String bigPicture = picturePath + "\\" + "EVENT_IVS_OBJECT_REMOVAL_DETECTION" + System.currentTimeMillis()
                                + ".jpg";
                        ToolKits.savePicture(pBuffer, msg.stuSceneImage.nOffSet, msg.stuSceneImage.nLength, bigPicture);
                    }
                    System.out.println(" 物品拿取检测事件 时间(UTC)：" + msg.UTC + " 通道号:" + msg.nChannelID + " 开始时间:"
                            + msg.stuObject.stuStartTime + " 结束时间:" + msg.stuObject.stuEndTime + " 事件ID:" + msg.nEventID + " 图片数量:" + msg.nImageInfoNum);
                    if(msg.nImageInfoNum > 0){
                        NET_IMAGE_INFO_EX2[] pstuImageInfo = new NET_IMAGE_INFO_EX2[msg.nImageInfoNum];
                        for(int i = 0; i < msg.nImageInfoNum; i ++){
                            pstuImageInfo[i] = new NET_IMAGE_INFO_EX2();
                        }
                        ToolKits.GetPointerDataToStructArr(msg.pstuImageInfo, pstuImageInfo);
                        for(int i = 0; i < msg.nImageInfoNum; i ++){
                            System.out.println("pstuImageInfo picture received!");
                            String bigPicture = picturePath + "\\" + System.currentTimeMillis() + "OBJECT_REMOVAL_DETECTION_" + i + ".jpg";
                            ToolKits.savePicture(pBuffer, pstuImageInfo[i].nOffset, pstuImageInfo[i].nLength, bigPicture);
                        }
                    }
                    EventDto dto = new EventDto();
                    dto.setEvent_name("物品拿取检测事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel( msg.nChannelID+"");
                    dto.setStuStartTime(msg.stuObject.stuStartTime+"");
                    dto.setEvent_utc_time(msg.UTC.toStringTime());
                    dto.setStuEndTime(msg.stuObject.stuEndTime+"");
                    dto.setEvent_id(msg.nEventID +"");
                    dto.setnImageInfoNum(msg.nImageInfoNum+"");
                    JdbcUtils.insert(dto);
                    break;
                }*/
                // 物品放置检测事件(对应 DEV_EVENT_OBJECT_PLACEMENT_DETECTION_INFO)
              /*  case EVENT_IVS_OBJECT_PLACEMENT_DETECTION: {
                    DEV_EVENT_OBJECT_PLACEMENT_DETECTION_INFO msg = new DEV_EVENT_OBJECT_PLACEMENT_DETECTION_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 全景广角图
                    if (msg.stuSceneImage != null && msg.stuSceneImage.nLength > 0) {
                        String bigPicture = picturePath + "\\" + "OBJECT_PLACEMENT_DETECTION" + System.currentTimeMillis()
                                + ".jpg";
                        ToolKits.savePicture(pBuffer, msg.stuSceneImage.nOffSet, msg.stuSceneImage.nLength, bigPicture);
                    }
                    System.out.println(" 物品放置检测事件 时间(UTC)：" + msg.UTC + " 通道号:" + msg.nChannelID + " 开始时间:"
                            + msg.stuObject.stuStartTime + " 结束时间:" + msg.stuObject.stuEndTime + " 事件ID:" + msg.nEventID + " 图片数量:" + msg.nImageInfoNum);
                    if(msg.nImageInfoNum > 0){
                        NET_IMAGE_INFO_EX2[] pstuImageInfo = new NET_IMAGE_INFO_EX2[msg.nImageInfoNum];
                        for(int i = 0; i < msg.nImageInfoNum; i ++){
                            pstuImageInfo[i] = new NET_IMAGE_INFO_EX2();
                        }
                        ToolKits.GetPointerDataToStructArr(msg.pstuImageInfo, pstuImageInfo);
                        for(int i = 0; i < msg.nImageInfoNum; i ++){
                            System.out.println("pstuImageInfo picture received!");
                            String bigPicture = picturePath + "\\" + System.currentTimeMillis() + "OBJECT_PLACEMENT_DETECTION_" + i + ".jpg";
                            ToolKits.savePicture(pBuffer, pstuImageInfo[i].nOffset, pstuImageInfo[i].nLength, bigPicture);
                        }
                    }
                    EventDto dto = new EventDto();
                    dto.setEvent_name("物品放置检测事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel( msg.nChannelID+"");
                    dto.setStuStartTime(msg.stuObject.stuStartTime+"");
                    dto.setEvent_utc_time(msg.UTC.toStringTime());
                    dto.setStuEndTime(msg.stuObject.stuEndTime+"");
                    dto.setEvent_id(msg.nEventID +"");
                    dto.setnImageInfoNum(msg.nImageInfoNum+"");
                    JdbcUtils.insert(dto);
                    break;
                }8?
               /* case EVENT_IVS_OBJECT_APPEAR_DETECTION: {// 目标出现事件(对应 NET_DEV_EVENT_OBJECT_APPEAR_DETECTION_INFO)
                    NET_DEV_EVENT_OBJECT_APPEAR_DETECTION_INFO msg = new NET_DEV_EVENT_OBJECT_APPEAR_DETECTION_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 全景广角图
                    if (msg.stuSceneImage != null && msg.stuSceneImage.nLength > 0) {
                        String bigPicture = picturePath + "\\" + "EVENT_IVS_OBJECT_APPEAR_DETECTION" + System.currentTimeMillis()
                                + ".jpg";
                        ToolKits.savePicture(pBuffer, msg.stuSceneImage.nOffSet, msg.stuSceneImage.nLength, bigPicture);
                    }
                    System.out.println(" 目标出现事件 时间(UTC)：" + msg.stuUTC + " 通道号:" + msg.nChannelID + " 事件ID:" + msg.nEventID + " 检测物体数量:" + msg.nObjectCount);
                    if(msg.nObjectCount > 0){
                        NetSDKLib.DH_MSG_OBJECT[] objects = new NetSDKLib.DH_MSG_OBJECT[msg.nObjectCount];
                        for(int i = 0; i < msg.nObjectCount; i ++){
                            objects[i] = new NetSDKLib.DH_MSG_OBJECT();
                        }
                        ToolKits.GetPointerDataToStructArr(msg.pstuObjects, objects);
                        for(int i = 0; i < msg.nObjectCount; i ++){
                            System.out.println("Object[" + i + "] 开始时间:"
                                    + objects[i].stuStartTime + " 结束时间:" + objects[i].stuEndTime );
                        }
                    }
                    EventDto dto = new EventDto();
                    dto.setEvent_name("目标出现事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel( msg.nChannelID+"");
                    dto.setnObjectCount(msg.nObjectCount+"");
                    dto.setEvent_utc_time(msg.stuUTC.toStringTime());
                    dto.setEvent_id(msg.nEventID +"");
                    JdbcUtils.insert(dto);
                    break;
                }*/
                // 目标消失事件(对应 NET_DEV_EVENT_OBJECT_DISAPPEAR_DETECTION_INFO)
               /* case EVENT_IVS_OBJECT_DISAPPEAR_DETECTION: {
                    NET_DEV_EVENT_OBJECT_DISAPPEAR_DETECTION_INFO msg = new NET_DEV_EVENT_OBJECT_DISAPPEAR_DETECTION_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 全景广角图
                    if (msg.stuSceneImage != null && msg.stuSceneImage.nLength > 0) {
                        String bigPicture = picturePath + "\\" + "EVENT_IVS_OBJECT_DISAPPEAR_DETECTION" + System.currentTimeMillis()
                                + ".jpg";
                        ToolKits.savePicture(pBuffer, msg.stuSceneImage.nOffSet, msg.stuSceneImage.nLength, bigPicture);
                    }
                    System.out.println(" 目标消失事件 时间(UTC)：" + msg.stuUTC + " 通道号:" + msg.nChannelID + " 事件ID:" + msg.nEventID + " 检测物体数量:" + msg.nObjectCount);
                    if(msg.nObjectCount > 0){
                        NetSDKLib.DH_MSG_OBJECT[] objects = new NetSDKLib.DH_MSG_OBJECT[msg.nObjectCount];
                        for(int i = 0; i < msg.nObjectCount; i ++){
                            objects[i] = new NetSDKLib.DH_MSG_OBJECT();
                        }
                        ToolKits.GetPointerDataToStructArr(msg.pstuObjects, objects);
                        for(int i = 0; i < msg.nObjectCount; i ++){
                            System.out.println("Object[" + i + "] 开始时间:"
                                    + objects[i].stuStartTime + " 结束时间:" + objects[i].stuEndTime );
                        }
                    }
                    EventDto dto = new EventDto();
                    dto.setEvent_name("目标消失事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel( msg.nChannelID+"");
                    dto.setnObjectCount(msg.nObjectCount+"");
                    dto.setEvent_utc_time(msg.stuUTC.toStringTime());
                    dto.setEvent_id(msg.nEventID +"");
                    JdbcUtils.insert(dto);
                    break;
                }*/
                // 目标状态事件(对应 NET_DEV_EVENT_OBJECT_STATE_DETECTION_INFO)
               /*  case EVENT_IVS_OBJECT_STATE_DETECTION: {
                    NET_DEV_EVENT_OBJECT_STATE_DETECTION_INFO msg = new NET_DEV_EVENT_OBJECT_STATE_DETECTION_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 全景广角图
                    if (msg.stuSceneImage != null && msg.stuSceneImage.nLength > 0) {
                        String bigPicture = picturePath + "\\" + "EVENT_IVS_OBJECT_STATE_DETECTION" + System.currentTimeMillis()
                                + ".jpg";
                        ToolKits.savePicture(pBuffer, msg.stuSceneImage.nOffSet, msg.stuSceneImage.nLength, bigPicture);
                    }
                    System.out.println(" 目标状态事件 时间(UTC)：" + msg.stuUTC + " 通道号:" + msg.nChannelID + " 事件ID:" + msg.nEventID + " 检测物体数量:" + msg.nObjectCount);
                    if(msg.nObjectCount > 0){
                        NetSDKLib.DH_MSG_OBJECT[] objects = new NetSDKLib.DH_MSG_OBJECT[msg.nObjectCount];
                        for(int i = 0; i < msg.nObjectCount; i ++){
                            objects[i] = new NetSDKLib.DH_MSG_OBJECT();
                        }
                        ToolKits.GetPointerDataToStructArr(msg.pstuObjects, objects);
                        for(int i = 0; i < msg.nObjectCount; i ++){
                            System.out.println("Object[" + i + "] 开始时间:"
                                    + objects[i].stuStartTime + " 结束时间:" + objects[i].stuEndTime );
                        }
                    }
                    EventDto dto = new EventDto();
                    dto.setEvent_name("目标状态事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel( msg.nChannelID+"");
                    dto.setnObjectCount(msg.nObjectCount+"");
                    dto.setEvent_utc_time(msg.stuUTC.toStringTime());
                    dto.setEvent_id(msg.nEventID +"");
                    JdbcUtils.insert(dto);
                    break;
                } */
                // 车位有车事件(对应 DEV_EVENT_TRAFFIC_PARKINGSPACEPARKING_INFO)
              /*   case EVENT_IVS_TRAFFIC_PARKINGSPACEPARKING: {
                    NetSDKLib.DEV_EVENT_TRAFFIC_PARKINGSPACEPARKING_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_PARKINGSPACEPARKING_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);

                    System.out.println(" 车位有车事件 时间(UTC)：" + msg.UTC + " 通道号:" + msg.nChannelID + " 事件ID:" + msg.nEventID  + " 图片数量:" + msg.nImageInfoNum);
                    // 停车图
                    if (msg.stuParkingImage != null && msg.stuParkingImage.nLength > 0) {
                        String bigPicture = picturePath + "\\" + "EVENT_IVS_TRAFFIC_PARKINGSPACEPARKING_" + System.currentTimeMillis()
                                + ".jpg";
                        ToolKits.savePicture(pBuffer, msg.stuParkingImage.nOffSet, msg.stuParkingImage.nLength, bigPicture);
                    }

                    //多图
                    if(msg.nImageInfoNum > 0){
                        NET_IMAGE_INFO_EX3[] objects = new NET_IMAGE_INFO_EX3[msg.nImageInfoNum];
                        for(int i = 0; i < msg.nImageInfoNum; i ++){
                            objects[i] = new NET_IMAGE_INFO_EX3();
                        }
                        ToolKits.GetPointerDataToStructArr(msg.pstuImageInfo, objects);
                        for(int i = 0; i < msg.nImageInfoNum; i ++){
                            String bigPicture = picturePath + "\\" + "EVENT_IVS_TRAFFIC_PARKINGSPACEPARKINGN_" + i + "_" + System.currentTimeMillis()
                                    + ".jpg";
                            System.out.println("Object[" + i + "] 偏移量:"
                                    + objects[i].nOffset + " 长度:" + objects[i].nLength + " 存储位置:" + bigPicture  );
                            ToolKits.savePicture(pBuffer, objects[i].nOffset, objects[i].nLength, bigPicture);
                        }
                    }
                    EventDto dto = new EventDto();
                    dto.setEvent_name("车位有车事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel( msg.nChannelID+"");
                    dto.setEvent_id(msg.nEventID +"");
                    dto.setnImageInfoNum(msg.nImageInfoNum+"");
                    JdbcUtils.insert(dto);
                    break;
                }
               /*  case EVENT_IVS_TRAFFIC_PARKINGSPACENOPARKING: {// 车位无车事件(对应 DEV_EVENT_TRAFFIC_PARKINGSPACENOPARKING_INFO)
                    NetSDKLib.DEV_EVENT_TRAFFIC_PARKINGSPACENOPARKING_INFO msg = new NetSDKLib.DEV_EVENT_TRAFFIC_PARKINGSPACENOPARKING_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);

                    System.out.println(" 车位无车事件 时间(UTC)：" + msg.UTC + " 通道号:" + msg.nChannelID + " 事件ID:" + msg.nEventID  + " 图片数量:" + msg.nImageInfoNum);
                    // 停车图
                    if (msg.stuParkingImage != null && msg.stuParkingImage.nLength > 0) {
                        String bigPicture = picturePath + "\\" + "EVENT_IVS_TRAFFIC_PARKINGSPACENOPARKING_" + System.currentTimeMillis()
                                + ".jpg";
                        ToolKits.savePicture(pBuffer, msg.stuParkingImage.nOffSet, msg.stuParkingImage.nLength, bigPicture);
                    }
                    //多图
                    if(msg.nImageInfoNum > 0){
                        NET_IMAGE_INFO_EX3[] objects = new NET_IMAGE_INFO_EX3[msg.nImageInfoNum];
                        for(int i = 0; i < msg.nImageInfoNum; i ++){
                            objects[i] = new NET_IMAGE_INFO_EX3();
                        }
                        ToolKits.GetPointerDataToStructArr(msg.pstuImageInfo, objects);
                        for(int i = 0; i < msg.nImageInfoNum; i ++){
                            String bigPicture = picturePath + "\\" + "EVENT_IVS_TRAFFIC_PARKINGSPACENOPARKING_" + i + "_" + System.currentTimeMillis()
                                    + ".jpg";
                            System.out.println("Object[" + i + "] 偏移量:"
                                    + objects[i].nOffset + " 长度:" + objects[i].nLength + " 存储位置:" + bigPicture  );
                            ToolKits.savePicture(pBuffer, objects[i].nOffset, objects[i].nLength, bigPicture);
                        }
                    }
                    EventDto dto = new EventDto();
                    dto.setEvent_name("车位无车事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel( msg.nChannelID+"");
                    dto.setEvent_id(msg.nEventID +"");
                    dto.setnImageInfoNum(msg.nImageInfoNum+"");
                    JdbcUtils.insert(dto);
                    break;
                }
                /* case EVENT_IVS_GENEAL_ATTITUDE: {// 通用姿态行为事件(对应 DEV_EVENT_GENEAL_ATTITUDE_INFO)
                    DEV_EVENT_GENEAL_ATTITUDE_INFO msg = new DEV_EVENT_GENEAL_ATTITUDE_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);

                    System.out.println(" 通用姿态行为事件 时间(UTC)：" + msg.stuUTC + " 通道号:" + msg.nChannelID + " 事件ID:" + msg.nEventID  + " 图片数量:" + msg.nImageInfoNum);
                    // 全景图
                    if (msg.stuSceneImage != null && msg.stuSceneImage.nLength > 0) {
                        String bigPicture = picturePath + "\\" + "EVENT_IVS_GENEAL_ATTITUDE_" + System.currentTimeMillis()
                                + "_fullScene.jpg";
                        ToolKits.savePicture(pBuffer, msg.stuSceneImage.nOffSet, msg.stuSceneImage.nLength, bigPicture);
                    }
                    //多图
                    if(msg.nImageInfoNum > 0){
                        NET_IMAGE_INFO_EX3[] objects = new NET_IMAGE_INFO_EX3[msg.nImageInfoNum];
                        for(int i = 0; i < msg.nImageInfoNum; i ++){
                            objects[i] = new NET_IMAGE_INFO_EX3();
                        }
                        ToolKits.GetPointerDataToStructArr(msg.pstuImageInfo, objects);
                        for(int i = 0; i < msg.nImageInfoNum; i ++){
                            String bigPicture = picturePath + "\\" + "EVENT_IVS_GENEAL_ATTITUDE_" + i + "_" + System.currentTimeMillis()
                                    + ".jpg";
                            System.out.println("Object[" + i + "] 偏移量:"
                                    + objects[i].nOffset + " 长度:" + objects[i].nLength + " 存储位置:" + bigPicture  );
                            ToolKits.savePicture(pBuffer, objects[i].nOffset, objects[i].nLength, bigPicture);
                        }
                    }
                    EventDto dto = new EventDto();
                    dto.setEvent_name("通用姿态行为事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel( msg.nChannelID+"");
                    dto.setEvent_utc_time(msg.stuUTC.toStringTime());
                    dto.setEvent_id(msg.nEventID +"");
                    dto.setnImageInfoNum(msg.nImageInfoNum+"");
                    JdbcUtils.insert(dto);
                    break;
                }
                /* case EVENT_IVS_ACTION_COUNT: {// 行为自定义行为计数事件(对应 NET_DEV_EVENT_ACTION_COUNT_INFO)
                    NET_DEV_EVENT_ACTION_COUNT_INFO msg = new NET_DEV_EVENT_ACTION_COUNT_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);

                    System.out.println(" 行为自定义行为计数事件 时间(UTC)：" + msg.stuUTC + " 通道号:" + msg.nChannelID + " 事件ID:" + msg.nEventID);
                    // 全景图
                    if (msg.stuSceneImage != null && msg.stuSceneImage.nLength > 0) {
                        String bigPicture = picturePath + "\\" + "EVENT_IVS_GENEAL_ATTITUDE_" + System.currentTimeMillis()
                                + "_fullScene.jpg";
                        ToolKits.savePicture(pBuffer, msg.stuSceneImage.nOffSet, msg.stuSceneImage.nLength, bigPicture);
                    }
                    EventDto dto = new EventDto();
                    dto.setEvent_name("行为自定义行为计数事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel( msg.nChannelID+"");
                    dto.setEvent_utc_time(msg.stuUTC.toStringTime());
                    dto.setEvent_id(msg.nEventID +"");
                    JdbcUtils.insert(dto);
                    break;
                }
                case EVENT_IVS_DROP_DETECTION: {// 滴漏检测事件(对应 NET_DEV_EVENT_DROP_DETECTION_INFO)
                    NET_DEV_EVENT_DROP_DETECTION_INFO msg = new NET_DEV_EVENT_DROP_DETECTION_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);

                    System.out.println(" 滴漏检测事件 时间(UTC)：" + msg.stuUTC + " 通道号:" + msg.nChannelID + " 事件ID:" + msg.nEventID);
                    // 全景图
                    if (msg.stuSceneImage != null && msg.stuSceneImage.nLength > 0) {
                        String bigPicture = picturePath + "\\" + "EVENT_IVS_DROP_DETECTION_" + System.currentTimeMillis()
                                + "_fullScene.jpg";
                        ToolKits.savePicture(pBuffer, msg.stuSceneImage.nOffSet, msg.stuSceneImage.nLength, bigPicture);
                    }
                    // 全图
                    if (pBuffer != null && dwBufSize > 0) {
                        String bigPicture = picturePath + "\\" + "EVENT_IVS_DROP_DETECTION_" + System.currentTimeMillis()
                                + "_full.jpg";
                        ToolKits.savePicture(pBuffer, 0, dwBufSize, bigPicture);
                    }
                    //多图
                    if(msg.nImageInfoNum > 0){
                        NET_IMAGE_INFO_EX3[] objects = new NET_IMAGE_INFO_EX3[msg.nImageInfoNum];
                        for(int i = 0; i < msg.nImageInfoNum; i ++){
                            objects[i] = new NET_IMAGE_INFO_EX3();
                        }
                        ToolKits.GetPointerDataToStructArr(msg.pstuImageInfo, objects);
                        for(int i = 0; i < msg.nImageInfoNum; i ++){
                            String bigPicture = picturePath + "\\" + "EVENT_IVS_GENEAL_ATTITUDE_" + i + "_" + System.currentTimeMillis()
                                    + ".jpg";
                            System.out.println("Object[" + i + "] 偏移量:"
                                    + objects[i].nOffset + " 长度:" + objects[i].nLength + " 存储位置:" + bigPicture  );
                            ToolKits.savePicture(pBuffer, objects[i].nOffset, objects[i].nLength, bigPicture);
                        }
                    }
                    EventDto dto = new EventDto();
                    dto.setEvent_name("滴漏检测事件");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel( msg.nChannelID+"");
                    dto.setEvent_utc_time(msg.stuUTC.toStringTime());
                    dto.setEvent_id(msg.nEventID +"");
                    JdbcUtils.insert(dto);
                    break;
                }
               case EVENT_IVS_WADING_DETECTION: {//涉水安全检测、水域监测报警(对应 NET_DEV_EVENT_WADING_DETECTION_INFO)

                    NET_DEV_EVENT_WADING_DETECTION_INFO msg = new NET_DEV_EVENT_WADING_DETECTION_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);

                    System.out.println(" 涉水安全检测、水域监测报警 时间(UTC)：" + msg.stuUTC + " 通道号:" + msg.nChannelID + " 事件ID:" + msg.nEventID
                            + " 事件名称-gbk:" + new String(msg.szName,"GBK").trim() + " 事件名称-utf-8:" + new String(msg.szName,"UTF-8").trim());
                    // 全图
                    if (pBuffer != null && dwBufSize > 0) {
                        String bigPicture = picturePath + "\\" + "EVENT_IVS_WADING_DETECTION_" + System.currentTimeMillis()
                                + "_full.jpg";
                        ToolKits.savePicture(pBuffer, 0, dwBufSize, bigPicture);
                    }
                    EventDto dto = new EventDto();
                    dto.setEvent_name("涉水安全检测");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel( msg.nChannelID+"");
                    dto.setEvent_utc_time(msg.stuUTC.toStringTime());
                    dto.setEvent_id(msg.nEventID +"");
                    dto.setSzName(new String(msg.szName,"UTF-8").trim());
                    JdbcUtils.insert(dto);
                    break;
                }*/
                // 交通能见度事件检测
               /* case EVENT_IVS_TRAFFIC_VISIBILITY:
                {
                    System.out.println("交通能见度事件检测, code = " + dwAlarmType);
                    DEV_EVENT_TRAFFIC_VISIBILITY_INFO msg = new DEV_EVENT_TRAFFIC_VISIBILITY_INFO();
                    ToolKits.GetPointerData(pAlarmInfo, msg);
                    // 通道号
                    int nChannelID = msg.nChannelID;
                    System.out.println("nChannelID:" + nChannelID);
                    // 动作
                    int nAction = msg.nAction;
                    System.out.println("nAction:" + nAction);
                    // 规则
                    int nRuleId = msg.nRuleId;
                    System.out.println("nRuleId:" + nRuleId);
                    // 能见程度
                    int nVisibility = msg.nVisibility;
                    System.out.println("nVisibility:" + nVisibility);
                    // 触发方式
                    int emTriggerType = msg.emTriggerType;
                    System.out.println("emTriggerType:" + emTriggerType + "," + EM_TRIGGER_TYPE.getNoteByValue(emTriggerType));
                    //事件名称
                    byte[] szName = msg.szName;
                    System.out.println("szName UTF-8:" + new String(szName,"UTF-8").trim());
                    System.out.println("szName GBK:" + new String(szName,"GBK").trim());
                    //相对事件时间戳(单位是毫秒)
                    double pts = msg.PTS;
                    System.out.println("pts:" + new Date((long) pts));
                    //事件id
                    int nEventID = msg.nEventID;
                    System.out.println("nEventID:" + nEventID);
                    //图片保存
                    if (pBuffer != null && dwBufSize > 0 && msg.stuCommInfo.nPictureNum > 0) {
                        System.out.println(msg.stuCommInfo.nPictureNum + " pictures received!");
                        for(int i = 0; i < msg.stuCommInfo.nPictureNum; i ++){
                            String bigPicture = picturePath + "\\" + System.currentTimeMillis() + "related_TrafficAccident_common_" + i + ".jpg";
                            ToolKits.savePicture(pBuffer, msg.stuCommInfo.stuPicInfos[i].nOffset, msg.stuCommInfo.stuPicInfos[i].nLength, bigPicture);
                        }
                    }
                    EventDto dto = new EventDto();
                    dto.setEvent_name("交通能见度事件检测");
                    dto.setEvent_code(dwAlarmType+"");
                    dto.setChannel(nChannelID+"");
                    dto.setnAction(nAction+"");
                    dto.setRule_Id(nRuleId+"");
                    dto.setnVisibility(nVisibility+"");
                    dto.setEmTriggerType(emTriggerType+"");
                    dto.setEvent_id(nEventID+"");
                    dto.setSzName(new String(szName,"UTF-8").trim());
                    dto.setEvent_time(DateUtil.format(new Date((long) pts), "yyyy-MM-dd HH:mm:ss.SSS"));
                    JdbcUtils.insert(dto);
                    break;

                }*/
                default:

                    break;
            }
            return 0;
        }
    }



    /**
     * 停止侦听智能事件
     */
    public void DetachEventRealLoadPic() {
        if (this.attachHandle.longValue() != 0) {
            netSdk.CLIENT_StopLoadPic(this.attachHandle);
        }
    }
    public void RunTest()
    {
        System.out.println("Run Test");
        CaseMenu menu = new CaseMenu();;
        menu.addItem((new CaseMenu.Item(this , "AttachEventRealLoadPic" , "AttachEventRealLoadPic")));
        menu.addItem((new CaseMenu.Item(this , "DetachEventRealLoadPic" , "DetachEventRealLoadPic")));

        menu.run();
    }

    public static void main(String[] args) {
        RealLoadPicExDemo realLoadPicExDemo= null;
        try {
            realLoadPicExDemo = new RealLoadPicExDemo();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }


        Initialization.InitTest("10.238.87.39", 37777, "admin", "huichen123!@#");
        realLoadPicExDemo.RunTest();
        LoginOut();

    }
}